Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPC Door handling #270

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion COGITO/Enemies/cogito_basic_enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,23 @@ func npc_footsteps(delta):
if !can_play_footstep and wiggle_vector.y < 0.9:
can_play_footstep = true


#Door handling
func _on_interaction_raycast_interactable_seen(interactable):
if interactable is CogitoDoor:
interact_with_door(interactable)

func interact_with_door(door: CogitoDoor):
if door.is_locked:
print("Door is locked.")
#TODO on NPC inventory addition, add key check here
door.audio_stream_player_3d.stream = door.rattle_sound
door.audio_stream_player_3d.play()
#TODO Recalculate path on locked door encountered, set avoidance around locked door
else:
if door.is_open:
door.close_door(self)
else:
door.open_door(self)

func load_patrol_points():
if patrol_path_nodepath:
Expand Down
10 changes: 9 additions & 1 deletion COGITO/Enemies/cogito_basic_enemy.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=24 format=3 uid="uid://dn4e1k7u3suoo"]
[gd_scene load_steps=25 format=3 uid="uid://dn4e1k7u3suoo"]

[ext_resource type="Script" path="res://COGITO/Enemies/cogito_basic_enemy.gd" id="1_0lcvu"]
[ext_resource type="Script" path="res://COGITO/CogitoObjects/cogito_security_camera.gd" id="2_6jysp"]
Expand All @@ -16,6 +16,7 @@
[ext_resource type="Script" path="res://COGITO/DynamicFootstepSystem/Scripts/footstep_surface_detector.gd" id="13_mhpd1"]
[ext_resource type="AudioStream" uid="uid://dc03jiw2a6y3j" path="res://COGITO/DynamicFootstepSystem/FootstepProfiles/generic_footstep_profile.tres" id="14_kpkpk"]
[ext_resource type="Resource" uid="uid://ca0q2t6w08ubh" path="res://COGITO/DynamicFootstepSystem/FootstepMaterialLibrary/sample_footstep_material_library.tres" id="15_vx81w"]
[ext_resource type="Script" path="res://COGITO/Scripts/interaction_raycast.gd" id="17_x20mi"]

[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_p3jhp"]
height = 1.8
Expand Down Expand Up @@ -135,5 +136,12 @@ footstep_material_library = ExtResource("15_vx81w")
generic_fallback_landing_profile = ExtResource("14_kpkpk")
landing_material_library = ExtResource("15_vx81w")

[node name="InteractionRaycast" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
target_position = Vector3(0, 0, -2.5)
collision_mask = 3
script = ExtResource("17_x20mi")

[connection signal="object_detected" from="SecurityCamera" to="." method="switch_to_chasing"]
[connection signal="object_no_longer_detected" from="SecurityCamera" to="." method="switch_to_patrolling"]
[connection signal="interactable_seen" from="InteractionRaycast" to="." method="_on_interaction_raycast_interactable_seen"]