From 19072e3f3ce97247fee89c44069144ca159a65bf Mon Sep 17 00:00:00 2001 From: niefia <99533148+niefia@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:01:51 +0100 Subject: [PATCH 1/3] Buttons & Switches interact to all bullets Buttons previously only activated with Hitscan weapon, now should activate with Projectiles Switches now react to both Hitscan & Projectiles --- COGITO/CogitoObjects/cogito_button.gd | 5 +++++ COGITO/CogitoObjects/cogito_switch.gd | 11 ++++++++-- .../DemoPrefabs/generic_button.tscn | 8 +++++++- .../DemoPrefabs/generic_switch.tscn | 20 ++++++++++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/COGITO/CogitoObjects/cogito_button.gd b/COGITO/CogitoObjects/cogito_button.gd index fbaac3e2..f6d3dcad 100644 --- a/COGITO/CogitoObjects/cogito_button.gd +++ b/COGITO/CogitoObjects/cogito_button.gd @@ -44,6 +44,11 @@ func _ready() -> void: cooldown = 0 #Enabling button to be pressed right away. interaction_text = usable_interaction_text object_state_updated.emit(interaction_text) + find_cogito_properties() +func find_cogito_properties(): + var property_nodes = find_children("","CogitoProperties",true) #Grabs all attached property components + if property_nodes: + cogito_properties = property_nodes[0] func _physics_process(delta: float) -> void: if cooldown > 0: diff --git a/COGITO/CogitoObjects/cogito_switch.gd b/COGITO/CogitoObjects/cogito_switch.gd index 81792e83..2486ea93 100644 --- a/COGITO/CogitoObjects/cogito_switch.gd +++ b/COGITO/CogitoObjects/cogito_switch.gd @@ -53,7 +53,12 @@ func _ready(): switch_on() else: switch_off() - + + find_cogito_properties() +func find_cogito_properties(): + var property_nodes = find_children("","CogitoProperties",true) #Grabs all attached property components + if property_nodes: + cogito_properties = property_nodes[0] func interact(_player_interaction_component): player_interaction_component = _player_interaction_component @@ -123,7 +128,9 @@ func check_for_item() -> bool: player_interaction_component.send_hint(null,item_hint) # Sends the key hint with the default hint icon. return false - +func _on_health_attribute_damage_taken(): + interact(CogitoSceneManager._current_player_node.player_interaction_component) + func set_state(): if is_on: for node in nodes_to_show_when_on: diff --git a/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn b/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn index 5618e711..47f33e3d 100644 --- a/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn +++ b/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=10 format=3 uid="uid://cs6raqlyejqul"] +[gd_scene load_steps=11 format=3 uid="uid://cs6raqlyejqul"] [ext_resource type="Script" path="res://COGITO/CogitoObjects/cogito_button.gd" id="1_l32yq"] [ext_resource type="AudioStream" uid="uid://b6wdy2102jymr" path="res://COGITO/Assets/Audio/Kenney/UiAudio/switch2.ogg" id="2_awyad"] [ext_resource type="PackedScene" uid="uid://l61jtpfxu5x5" path="res://COGITO/Components/Interactions/BasicInteraction.tscn" id="3_v8dn1"] [ext_resource type="PackedScene" uid="uid://cqgg1nng0vvbh" path="res://COGITO/Components/Attributes/HealthAttribute.tscn" id="4_26rcl"] [ext_resource type="PackedScene" uid="uid://k28yrbg3k3pw" path="res://COGITO/Components/HitboxComponent.tscn" id="5_dudfk"] +[ext_resource type="PackedScene" uid="uid://cj0yaeh3yg7tu" path="res://COGITO/Components/Properties/CogitoProperties.tscn" id="6_w5n86"] [sub_resource type="CylinderMesh" id="CylinderMesh_clo4d"] top_radius = 0.05 @@ -51,4 +52,9 @@ is_locked = true [node name="HitboxComponent" parent="." node_paths=PackedStringArray("health_attribute") instance=ExtResource("5_dudfk")] health_attribute = NodePath("../HealthAttribute") +[node name="CogitoProperties" parent="." instance=ExtResource("6_w5n86")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42562, 0) +material_properties = 1 +burn_damage_amount = 1.0 + [connection signal="damage_taken" from="HealthAttribute" to="." method="on_damage_received"] diff --git a/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn b/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn index 37cdc7d7..413ac392 100644 --- a/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn +++ b/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn @@ -1,8 +1,11 @@ -[gd_scene load_steps=9 format=3 uid="uid://6k5rvlwcpys1"] +[gd_scene load_steps=12 format=3 uid="uid://6k5rvlwcpys1"] [ext_resource type="Script" path="res://COGITO/CogitoObjects/cogito_switch.gd" id="1_8r8fc"] [ext_resource type="AudioStream" uid="uid://0himm415mqex" path="res://COGITO/Assets/Audio/Kenney/UiAudio/switch29.ogg" id="2_m3jxc"] [ext_resource type="PackedScene" uid="uid://l61jtpfxu5x5" path="res://COGITO/Components/Interactions/BasicInteraction.tscn" id="3_v8dn1"] +[ext_resource type="PackedScene" uid="uid://k28yrbg3k3pw" path="res://COGITO/Components/HitboxComponent.tscn" id="4_dkn68"] +[ext_resource type="PackedScene" uid="uid://cj0yaeh3yg7tu" path="res://COGITO/Components/Properties/CogitoProperties.tscn" id="5_mihmv"] +[ext_resource type="PackedScene" uid="uid://cqgg1nng0vvbh" path="res://COGITO/Components/Attributes/HealthAttribute.tscn" id="6_1cnu2"] [sub_resource type="CylinderMesh" id="CylinderMesh_clo4d"] top_radius = 0.05 @@ -53,3 +56,18 @@ shape = SubResource("BoxShape3D_nti18") [node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."] [node name="BasicInteraction" parent="." instance=ExtResource("3_v8dn1")] + +[node name="HitboxComponent" parent="." node_paths=PackedStringArray("health_attribute") instance=ExtResource("4_dkn68")] +health_attribute = NodePath("../HealthAttribute") + +[node name="CogitoProperties" parent="." instance=ExtResource("5_mihmv")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42562, 0) +material_properties = 1 +burn_damage_amount = 1.0 + +[node name="HealthAttribute" parent="." instance=ExtResource("6_1cnu2")] +value_max = 1.0 +value_start = 1.0 +is_locked = true + +[connection signal="damage_taken" from="HealthAttribute" to="." method="_on_health_attribute_damage_taken"] From 24c797c093b67e68e7ed3576dc4b6dad50eda38a Mon Sep 17 00:00:00 2001 From: niefia <99533148+niefia@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:37:07 +0100 Subject: [PATCH 2/3] Removed Health attribute Removed Health attribute, Hitbox directly calls the _on_damage_received to interact --- COGITO/CogitoObjects/cogito_button.gd | 2 +- COGITO/CogitoObjects/cogito_switch.gd | 6 +++--- COGITO/DemoScenes/DemoPrefabs/generic_button.tscn | 13 +++---------- COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn | 13 +++---------- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/COGITO/CogitoObjects/cogito_button.gd b/COGITO/CogitoObjects/cogito_button.gd index f6d3dcad..b7be5443 100644 --- a/COGITO/CogitoObjects/cogito_button.gd +++ b/COGITO/CogitoObjects/cogito_button.gd @@ -90,7 +90,7 @@ func press(): object.interact(player_interaction_component) -func on_damage_received(): +func _on_damage_received(): interact(CogitoSceneManager._current_player_node.player_interaction_component) diff --git a/COGITO/CogitoObjects/cogito_switch.gd b/COGITO/CogitoObjects/cogito_switch.gd index 2486ea93..90802c03 100644 --- a/COGITO/CogitoObjects/cogito_switch.gd +++ b/COGITO/CogitoObjects/cogito_switch.gd @@ -128,9 +128,9 @@ func check_for_item() -> bool: player_interaction_component.send_hint(null,item_hint) # Sends the key hint with the default hint icon. return false -func _on_health_attribute_damage_taken(): +func _on_damage_received(): interact(CogitoSceneManager._current_player_node.player_interaction_component) - + func set_state(): if is_on: for node in nodes_to_show_when_on: @@ -151,7 +151,6 @@ func set_state(): object_state_updated.emit(interaction_text) - func save(): var state_dict = { "node_path" : self.get_path(), @@ -165,3 +164,4 @@ func save(): } return state_dict + diff --git a/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn b/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn index 47f33e3d..0942a78f 100644 --- a/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn +++ b/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=11 format=3 uid="uid://cs6raqlyejqul"] +[gd_scene load_steps=10 format=3 uid="uid://cs6raqlyejqul"] [ext_resource type="Script" path="res://COGITO/CogitoObjects/cogito_button.gd" id="1_l32yq"] [ext_resource type="AudioStream" uid="uid://b6wdy2102jymr" path="res://COGITO/Assets/Audio/Kenney/UiAudio/switch2.ogg" id="2_awyad"] [ext_resource type="PackedScene" uid="uid://l61jtpfxu5x5" path="res://COGITO/Components/Interactions/BasicInteraction.tscn" id="3_v8dn1"] -[ext_resource type="PackedScene" uid="uid://cqgg1nng0vvbh" path="res://COGITO/Components/Attributes/HealthAttribute.tscn" id="4_26rcl"] [ext_resource type="PackedScene" uid="uid://k28yrbg3k3pw" path="res://COGITO/Components/HitboxComponent.tscn" id="5_dudfk"] [ext_resource type="PackedScene" uid="uid://cj0yaeh3yg7tu" path="res://COGITO/Components/Properties/CogitoProperties.tscn" id="6_w5n86"] @@ -44,17 +43,11 @@ shape = SubResource("BoxShape3D_nti18") [node name="BasicInteraction" parent="." instance=ExtResource("3_v8dn1")] -[node name="HealthAttribute" parent="." instance=ExtResource("4_26rcl")] -value_max = 1.0 -value_start = 1.0 -is_locked = true - -[node name="HitboxComponent" parent="." node_paths=PackedStringArray("health_attribute") instance=ExtResource("5_dudfk")] -health_attribute = NodePath("../HealthAttribute") +[node name="HitboxComponent" parent="." instance=ExtResource("5_dudfk")] [node name="CogitoProperties" parent="." instance=ExtResource("6_w5n86")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42562, 0) material_properties = 1 burn_damage_amount = 1.0 -[connection signal="damage_taken" from="HealthAttribute" to="." method="on_damage_received"] +[connection signal="damage_received" from="." to="." method="_on_damage_received"] diff --git a/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn b/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn index 413ac392..2bcd48a4 100644 --- a/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn +++ b/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=12 format=3 uid="uid://6k5rvlwcpys1"] +[gd_scene load_steps=11 format=3 uid="uid://6k5rvlwcpys1"] [ext_resource type="Script" path="res://COGITO/CogitoObjects/cogito_switch.gd" id="1_8r8fc"] [ext_resource type="AudioStream" uid="uid://0himm415mqex" path="res://COGITO/Assets/Audio/Kenney/UiAudio/switch29.ogg" id="2_m3jxc"] [ext_resource type="PackedScene" uid="uid://l61jtpfxu5x5" path="res://COGITO/Components/Interactions/BasicInteraction.tscn" id="3_v8dn1"] [ext_resource type="PackedScene" uid="uid://k28yrbg3k3pw" path="res://COGITO/Components/HitboxComponent.tscn" id="4_dkn68"] [ext_resource type="PackedScene" uid="uid://cj0yaeh3yg7tu" path="res://COGITO/Components/Properties/CogitoProperties.tscn" id="5_mihmv"] -[ext_resource type="PackedScene" uid="uid://cqgg1nng0vvbh" path="res://COGITO/Components/Attributes/HealthAttribute.tscn" id="6_1cnu2"] [sub_resource type="CylinderMesh" id="CylinderMesh_clo4d"] top_radius = 0.05 @@ -57,17 +56,11 @@ shape = SubResource("BoxShape3D_nti18") [node name="BasicInteraction" parent="." instance=ExtResource("3_v8dn1")] -[node name="HitboxComponent" parent="." node_paths=PackedStringArray("health_attribute") instance=ExtResource("4_dkn68")] -health_attribute = NodePath("../HealthAttribute") +[node name="HitboxComponent" parent="." instance=ExtResource("4_dkn68")] [node name="CogitoProperties" parent="." instance=ExtResource("5_mihmv")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42562, 0) material_properties = 1 burn_damage_amount = 1.0 -[node name="HealthAttribute" parent="." instance=ExtResource("6_1cnu2")] -value_max = 1.0 -value_start = 1.0 -is_locked = true - -[connection signal="damage_taken" from="HealthAttribute" to="." method="_on_health_attribute_damage_taken"] +[connection signal="damage_received" from="." to="." method="_on_damage_received"] From 91ee06f0bad91a22bf3be320fd7640f7c602bf02 Mon Sep 17 00:00:00 2001 From: niefia <99533148+niefia@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:47:30 +0100 Subject: [PATCH 3/3] Recentred transform on CogitoProperties ndoes --- COGITO/DemoScenes/DemoPrefabs/generic_button.tscn | 1 - COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn | 1 - 2 files changed, 2 deletions(-) diff --git a/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn b/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn index 0942a78f..075a24d3 100644 --- a/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn +++ b/COGITO/DemoScenes/DemoPrefabs/generic_button.tscn @@ -46,7 +46,6 @@ shape = SubResource("BoxShape3D_nti18") [node name="HitboxComponent" parent="." instance=ExtResource("5_dudfk")] [node name="CogitoProperties" parent="." instance=ExtResource("6_w5n86")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42562, 0) material_properties = 1 burn_damage_amount = 1.0 diff --git a/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn b/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn index 2bcd48a4..62391f2d 100644 --- a/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn +++ b/COGITO/DemoScenes/DemoPrefabs/generic_switch.tscn @@ -59,7 +59,6 @@ shape = SubResource("BoxShape3D_nti18") [node name="HitboxComponent" parent="." instance=ExtResource("4_dkn68")] [node name="CogitoProperties" parent="." instance=ExtResource("5_mihmv")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42562, 0) material_properties = 1 burn_damage_amount = 1.0