OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-tps_demo commits / 9e1ef92

added ominlight to player toggleable with key x
9e1ef92d3600fd1b274a6d314fb9ab18194432c5
by Dresk Spidflisk <dreskspidflisk@gmail.com> · 2022-04-14T20:32:38.000Z

Changed files (8) +68 -1

assets/sounds/player/toggleLight_1.wav +0 -0
(no content changes — binary or rename)
assets/sounds/player/toggleLight_1.wav.import +21 -0
……@@ -0,0 +1,21 @@
1[remap]
2
3importer="wav"
4type="AudioStreamSample"
5path="res://.import/toggleLight_1.wav-3c6b6158e5cc6bccea829ac956df6645.sample"
6
7[deps]
8
9source_file="res://assets/sounds/player/toggleLight_1.wav"
10dest_files=[ "res://.import/toggleLight_1.wav-3c6b6158e5cc6bccea829ac956df6645.sample" ]
11
12[params]
13
14force/8_bit=false
15force/mono=false
16force/max_rate=false
17force/max_rate_hz=44100
18edit/trim=false
19edit/normalize=false
20edit/loop=false
21compress/mode=0
game/player/player_core.gd +14 -0
……@@ -9,6 +9,7 @@ const EVENT_PLAYER_DIRECTION = 'player_direction'
99const EVENT_PLAYER_RESPAWNPLAYER = 'player_respawnplayer'
1010const EVENT_PLAYER_SHOOT_GRAPPLINGHOOK = 'player_shoot_grapplinghook'
1111const EVENT_PLAYER_RELEASE_GRAPPLINGHOOK = 'player_release_grapplinghook'
12const EVENT_PLAYER_TOGGLE_LIGHT = 'player_toggle_light'
1213
1314export var mouseSensitivity : float = 0.3
1415export var movementSpeed : float = 14
……@@ -47,6 +48,8 @@ onready var grappleVisualLine : CSGCylinder = $Model/GrappleLineHelper/GrappleVi
4748onready var grappleIKTarget : Position3D = $GrapplingHook/IKTarget
4849onready var grapplingHandOriginalScale : Vector3 = Vector3.ZERO
4950
51onready var omniLight : OmniLight = $OmniLight
52
5053var grapplingHook_GrapplePosition : Vector3 = Vector3.ZERO
5154var grapplingHook_IsHooked : bool = false
5255var playerWantsToShootGrapplingHook : bool = false
……@@ -70,6 +73,7 @@ var playerCanJump : bool = false
7073var playerWantsToJump : bool = false
7174
7275var playerWantsNewWorldEnvironment : bool = true
76var playerWantsToToggleLight : bool = false
7377
7478var f_input : float
7579var h_input : float
……@@ -208,6 +212,12 @@ func _physics_process(_delta):
208212 if(playerWantsNewWorldEnvironment):
209213 playerWantsNewWorldEnvironment = false
210214 currentMap.updateMapWorldEnvironmentScene()
215
216 # Check for Toggle Light
217 if(playerWantsToToggleLight):
218 playerWantsToToggleLight = false
219 omniLight.visible = !omniLight.visible
220 $Model/Sound_ToggleLight_1.play()
211221
212222 # Moving the character
213223 var y_cache : float = kinematicVelocity.y
……@@ -380,6 +390,10 @@ func _on_Input_player_release_grapplinghook():
380390 if(grapplingHook_IsHooked):
381391 playerWantsToReleaseGrapplingHook = true
382392 hyperGossip.broadcast_event(EVENT_PLAYER_RELEASE_GRAPPLINGHOOK, getPlayerLocalCoreNetworkData() )
393
394func _on_Input_player_toggle_light():
395 playerWantsToToggleLight = true
396 hyperGossip.broadcast_event(EVENT_PLAYER_TOGGLE_LIGHT, getPlayerLocalCoreNetworkData() )
383397
384398
385399func _checkPlayerCanJump(newBody : PhysicsBody, addedBody : bool) -> void:
game/player/player_core.tscn +14 -1
……@@ -1,4 +1,4 @@
1[gd_scene load_steps=36 format=2]
1[gd_scene load_steps=37 format=2]
22
33[ext_resource path="res://assets/models/tumble/model_tumble.tscn" type="PackedScene" id=1]
44[ext_resource path="res://assets/models/tumble/tumble/sprint-loop.tres" type="Animation" id=2]
……@@ -34,6 +34,7 @@
3434[ext_resource path="res://assets/sounds/player/fire_grapplinghook1.mp3" type="AudioStream" id=32]
3535[ext_resource path="res://assets/sounds/player/teleport_1.mp3" type="AudioStream" id=33]
3636[ext_resource path="res://game/player/grappling_hook/gh_visual_line_1.tscn" type="PackedScene" id=34]
37[ext_resource path="res://assets/sounds/player/toggleLight_1.wav" type="AudioStream" id=35]
3738
3839[sub_resource type="CylinderShape" id=1]
3940radius = 0.3
……@@ -87,6 +88,11 @@ transform = Transform( 1.53846, 0, 0, 0, 1.53846, 0, 0, 0, 1.53846, 0, 0, 0 )
8788stream = ExtResource( 33 )
8889attenuation_filter_cutoff_hz = 20500.0
8990
91[node name="Sound_ToggleLight_1" type="AudioStreamPlayer3D" parent="Model"]
92transform = Transform( 1.53846, 0, 0, 0, 1.53846, 0, 0, 0, 1.53846, 0, 0, 0 )
93stream = ExtResource( 35 )
94attenuation_filter_cutoff_hz = 20500.0
95
9096[node name="GrappleLineHelper" type="Spatial" parent="Model"]
9197transform = Transform( 1.53846, 0, 0, 0, 1.53846, 0, 0, 0, 1.53846, 0, 0.753, 0 )
9298
……@@ -148,4 +154,11 @@ autostart = true
148154[node name="IKTarget" type="Position3D" parent="GrapplingHook"]
149155transform = Transform( -0.454202, 0.376862, -0.807264, 0.862653, -0.0403142, -0.504187, -0.222553, -0.925392, -0.30679, 0, 0.96284, -1.2328 )
150156
157[node name="OmniLight" type="OmniLight" parent="."]
158transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.769087, 0 )
159visible = false
160light_energy = 5.194
161shadow_color = Color( 1, 1, 1, 1 )
162omni_range = 2.23
163
151164[connection signal="timeout" from="MoveNetworkTimer" to="." method="_on_MoveNetworkTimer_timeout"]
game/player/player_core_local.tscn +1 -0
……@@ -54,5 +54,6 @@ far = 8192.0
5454[connection signal="player_release_grapplinghook" from="Input" to="." method="_on_Input_player_release_grapplinghook"]
5555[connection signal="player_restore_origin" from="Input" to="." method="_on_Input_player_restore_origin"]
5656[connection signal="player_shoot_grapplinghook" from="Input" to="." method="_on_Input_player_shoot_grapplinghook"]
57[connection signal="player_toggle_light" from="Input" to="." method="_on_Input_player_toggle_light"]
5758
5859[editable path="Model"]
game/player/player_core_local_input.gd +4 -0
……@@ -11,6 +11,7 @@ signal player_jump()
1111signal player_move(inputDirection)
1212signal player_shoot_grapplinghook()
1313signal player_release_grapplinghook()
14signal player_toggle_light()
1415# signal player_shoot()
1516
1617var previousInputDirection : Vector3 = Vector3.ZERO
……@@ -62,6 +63,9 @@ func _input(event : InputEvent):
6263 if event.is_action_pressed("restoreOrigin"):
6364 emit_signal("player_restore_origin")
6465
66 if event.is_action_pressed("toggleLight"):
67 emit_signal("player_toggle_light")
68
6569 #if Input.is_action_pressed("forward") || Input.is_action_pressed("backward") || Input.is_action_pressed("left") || Input.is_action_pressed("right"):
6670 # movementDirection = Vector3.ZERO
6771 # movementDirection = Vector3(Input.get_action_strength("left") - Input.get_action_strength("right"),
hypergodot/hyper_godot_core.gd +9 -0
……@@ -15,6 +15,7 @@ const EVENT_PLAYER_RESPAWNPLAYER = 'player_respawnplayer'
1515const EVENT_PLAYER_MAPCHANGE = 'player_mapchange'
1616const EVENT_PLAYER_SHOOT_GRAPPLINGHOOK = 'player_shoot_grapplinghook'
1717const EVENT_PLAYER_RELEASE_GRAPPLINGHOOK = 'player_release_grapplinghook'
18const EVENT_PLAYER_TOGGLE_LIGHT = 'player_toggle_light'
1819
1920var PlayerCoreLocal = preload("res://game/player/player_core_local.tscn")
2021var PlayerCoreRemote = preload("res://game/player/player_core_remote.tscn")
……@@ -80,6 +81,8 @@ func _on_HyperGossip_event(type, data, from):
8081 updatePlayer_shootGrapplingHook(data, from)
8182 elif type == EVENT_PLAYER_RELEASE_GRAPPLINGHOOK:
8283 updatePlayer_releaseGrapplingHook(data, from)
84 elif type == EVENT_PLAYER_TOGGLE_LIGHT:
85 updatePlayer_toggleLight(data, from)
8386
8487func get_player_object(id):
8588 if knownPlayers.has(id):
……@@ -131,6 +134,12 @@ func updatePlayer_wantstojump(data, id):
131134 remotePlayer.playerCoreNetworkDataUpdate(data)
132135 remotePlayer.playerWantsToJump = true
133136
137func updatePlayer_toggleLight(data, id):
138 var remotePlayer = get_player_object(id)
139
140 remotePlayer.playerCoreNetworkDataUpdate(data)
141 remotePlayer.playerWantsToToggleLight = true
142
134143func updatePlayer_mapchange(data, _id):
135144 var newMapName = data.map.name
136145 # TODO : Do this elsewhere
project.godot +5 -0
……@@ -160,6 +160,11 @@ toggle_slowmo={
160160"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
161161 ]
162162}
163toggleLight={
164"deadzone": 0.5,
165"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
166 ]
167}
163168
164169[physics]
165170