diff --git a/maps/_templates/MainSceneTemplate.cs b/maps/_templates/MainSceneTemplate.cs new file mode 100644 index 00000000..d9bdfdcb --- /dev/null +++ b/maps/_templates/MainSceneTemplate.cs @@ -0,0 +1,67 @@ +using Godot; +using System; +using Movementtests.interfaces; +using Movementtests.systems; + +public partial class MainSceneTemplate : Node3D +{ + private Marker3D? _playerRespawnMarker; + private AnimationPlayer? _animationPlayer; + private Node3D? _respawnabble; + + private Area3D? _playerFellPlane; + private Area3D? _deathPlane; + + public override void _Ready() + { + _playerRespawnMarker = GetNode("PlayerFellRespawn"); + _animationPlayer = GetNode("AnimationPlayer"); + + _playerFellPlane = GetNode("PlayerFellTP"); + _deathPlane = GetNode("DeathPlane"); + + if (_playerRespawnMarker == null) throw new Exception("Player respawn marker is null"); + if (_animationPlayer == null) throw new Exception("Animation player is null"); + if (_playerFellPlane == null) throw new Exception("Player reset plane is null"); + if (_deathPlane == null) throw new Exception("Enemy death plane is null"); + + _playerFellPlane.BodyEntered += StartResetPlayerAnimation; + _deathPlane.BodyEntered += KillEnemy; + + } + + public void ResetPlayerPosition() + { + if (_respawnabble == null || _playerRespawnMarker == null) throw new Exception("Player or respawn marker is null"); + _respawnabble.GlobalPosition = _playerRespawnMarker.GlobalPosition; + } + + public void StartResetPlayerAnimation(Node3D body) + { + if (body is WeaponSystem weapon) + { + if (_playerRespawnMarker == null) throw new Exception("Respawn marker is null"); + weapon.GlobalPosition = _playerRespawnMarker.GlobalPosition; + weapon.SetLinearVelocity(Vector3.Down); + return; + } + _respawnabble = body as PlayerController; + if (_respawnabble == null || _animationPlayer == null) throw new Exception("Player or anim player is null"); + _animationPlayer.Play("player_fell"); + } + + public void KillEnemy(Node3D body) + { + if (body is not IKillable killable) + { + body.QueueFree(); + return; + } + if (killable is not IHealthable healthable) + { + body.QueueFree(); + return; + } + killable.Kill(healthable); + } +} diff --git a/maps/_templates/MainSceneTemplate.cs.uid b/maps/_templates/MainSceneTemplate.cs.uid new file mode 100644 index 00000000..bddb92a5 --- /dev/null +++ b/maps/_templates/MainSceneTemplate.cs.uid @@ -0,0 +1 @@ +uid://br0f18u1iou2d diff --git a/maps/_templates/main_scene_template.gd b/maps/_templates/main_scene_template.gd deleted file mode 100644 index 03da94e6..00000000 --- a/maps/_templates/main_scene_template.gd +++ /dev/null @@ -1,21 +0,0 @@ -extends Node3D - - -@onready var player_fell_respawn: Marker3D = $PlayerFellRespawn -@onready var animation_player: AnimationPlayer = $AnimationPlayer - -var _player: Node3D - -func _on_player_fell_tp_body_entered(body: Node3D) -> void: - _player = body - animation_player.play("player_fell") - - -func reset_player_position() -> void: - if _player == null: - return - _player.position = player_fell_respawn.position - - -func _on_death_plane_body_entered(body: Node3D) -> void: - body.queue_free() diff --git a/maps/_templates/main_scene_template.gd.uid b/maps/_templates/main_scene_template.gd.uid deleted file mode 100644 index 37d8c11c..00000000 --- a/maps/_templates/main_scene_template.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://beof168aw2acj diff --git a/maps/_templates/main_scene_template.tscn b/maps/_templates/main_scene_template.tscn index fe82247e..b9f73e97 100644 --- a/maps/_templates/main_scene_template.tscn +++ b/maps/_templates/main_scene_template.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://55wehh6xombr"] -[ext_resource type="Script" uid="uid://beof168aw2acj" path="res://maps/_templates/main_scene_template.gd" id="1_5g5a0"] +[ext_resource type="Script" uid="uid://br0f18u1iou2d" path="res://maps/_templates/MainSceneTemplate.cs" id="1_5g5a0"] [ext_resource type="PackedScene" uid="uid://bkcsjsk2ciff" path="res://addons/maaacks_game_template/base/scenes/music_players/background_music_player.tscn" id="2_roiv2"] [ext_resource type="AudioStream" uid="uid://f8cvr5s041ej" path="res://assets/audio/ambiance/637083__nox_sound__ambiance_nature_night_cricket_calm_loop_stereo.wav" id="3_boadi"] [ext_resource type="Script" uid="uid://cupqhe3qv7ero" path="res://tools/general_manager.gd" id="3_k6got"] @@ -237,7 +237,7 @@ tracks/6/keys = { "transitions": PackedFloat32Array(1), "values": [{ "args": [], -"method": &"reset_player_position" +"method": &"ResetPlayerPosition" }] } @@ -300,6 +300,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 300, 0) [node name="PlayerFellTP" type="Area3D" parent="." unique_id=1277888169] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -200, 0) collision_layer = 0 +collision_mask = 65537 monitorable = false [node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerFellTP" unique_id=1866249040] diff --git a/maps/levels/1 - tuto_movement.tscn b/maps/levels/1 - tuto_movement.tscn index 17dca72e..cf0a0712 100644 --- a/maps/levels/1 - tuto_movement.tscn +++ b/maps/levels/1 - tuto_movement.tscn @@ -41,7 +41,7 @@ size = Vector3(6.75, 8.25, 7.25) [node name="Main" unique_id=955321579 instance=ExtResource("1_jyq54")] -[node name="DirectionalLight3D" parent="." index="5" unique_id=1357990191] +[node name="DirectionalLight3D" parent="." index="6" unique_id=1357990191] transform = Transform3D(-0.1772511, 0.44628847, 0.87715954, 0.49540228, -0.72966087, 0.4713508, 0.85038733, 0.51809436, -0.09175911, 0, 0, 0) [node name="Greybox" type="CSGCombiner3D" parent="." index="7" unique_id=2082385716] @@ -907,9 +907,9 @@ light_energy = 8.571 omni_range = 7.0 [node name="OmniLight3D29" type="OmniLight3D" parent="Lights" index="24" unique_id=2143811783] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 25.5, -16.5) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 16.75, -18.75) light_energy = 4.004 -omni_range = 7.0 +omni_range = 9.25 [node name="OmniLight3D20" type="OmniLight3D" parent="Lights" index="25" unique_id=1665621589] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 24.5, -35.25) @@ -934,14 +934,19 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -33.5, 24.5, -47) light_energy = 2.725 omni_range = 10.0 -[node name="OmniLight3D25" type="OmniLight3D" parent="Lights" index="30" unique_id=727558952] +[node name="OmniLight3D34" type="OmniLight3D" parent="Lights" index="30" unique_id=2065211844] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -36.25, 13.75, -45.5) +light_energy = 2.725 +omni_range = 10.0 + +[node name="OmniLight3D25" type="OmniLight3D" parent="Lights" index="31" unique_id=727558952] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -28, 24.5, -51) -[node name="OmniLight3D26" type="OmniLight3D" parent="Lights" index="31" unique_id=1646376304] +[node name="OmniLight3D26" type="OmniLight3D" parent="Lights" index="32" unique_id=1646376304] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 24.5, -51.5) omni_range = 7.0 -[node name="OmniLight3D27" type="OmniLight3D" parent="Lights" index="32" unique_id=1849438050] +[node name="OmniLight3D27" type="OmniLight3D" parent="Lights" index="33" unique_id=1849438050] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 24.5, -51.5) omni_range = 4.5 @@ -1047,10 +1052,10 @@ tuto_text = "Select next level when ready" transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.875, 1.125, -4.625) shape = SubResource("BoxShape3D_7hd1j") -[node name="Player" parent="." index="11" unique_id=1309399929] +[node name="Player" parent="." index="12" unique_id=1309399929] transform = Transform3D(0.99999994, 0, 0, 0, 1, 0, 0, 0, 0.99999994, -0.5, 0.4102497, 0.5415039) HasSword = false HasParry = false -[node name="PlayerFellRespawn" parent="." index="12" unique_id=479136076] +[node name="PlayerFellRespawn" parent="." index="13" unique_id=479136076] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.25, -1.25) diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index 7a2d8d5b..12bf553e 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -2318,13 +2318,13 @@ public partial class PlayerController : CharacterBody3D, // Manage gameplay systems MantleSystem.ProcessMantle(_grounded.Active); HandleEnemyTargeting(); + // Manage head and camera movement + LookAround(delta); } // private float _oldMana = 100; public override void _Process(double delta) { - // Manage head and camera movement - LookAround(delta); EffectsManager.UpdateEffects(delta); }