diff --git a/maps/city.tscn b/maps/city.tscn index 07b7d60a..eaede950 100644 --- a/maps/city.tscn +++ b/maps/city.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=17 format=3 uid="uid://dmkw8cmalm5k"] +[gd_scene load_steps=19 format=3 uid="uid://dmkw8cmalm5k"] [ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://player_controller/PlayerController.tscn" id="1_2vsi6"] [ext_resource type="Texture2D" uid="uid://ca4kkq3w8cd4n" path="res://assets/sky/sky_15_2k.png" id="2_ruo5i"] @@ -13,6 +13,7 @@ [ext_resource type="PackedScene" uid="uid://dip6cce5gtwi8" path="res://assets/greyboxing/guard_tower.tscn" id="11_wctvs"] [ext_resource type="PackedScene" uid="uid://c066hc7yu36wx" path="res://assets/water/water.tscn" id="12_i2xii"] [ext_resource type="PackedScene" uid="uid://gir68sk3762e" path="res://assets/lift/lift.tscn" id="13_eca4n"] +[ext_resource type="CylinderMesh" uid="uid://bhkbwvuft1bpg" path="res://systems/weapon/weapon_tuto.tres" id="14_0ari0"] [sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_feb1n"] panorama = ExtResource("2_ruo5i") @@ -28,6 +29,7 @@ reflected_light_source = 2 tonemap_mode = 4 ssao_enabled = true ssil_enabled = true +sdfgi_enabled = true sdfgi_use_occlusion = true fog_enabled = true fog_light_color = Color(0.9955967, 0.83634025, 0.69151855, 1) @@ -38,10 +40,15 @@ volumetric_fog_density = 0.004 volumetric_fog_emission = Color(1, 1, 1, 1) volumetric_fog_anisotropy = 0.6 +[sub_resource type="BoxShape3D" id="BoxShape3D_0ari0"] +size = Vector3(11.5, 9, 4.5) + [node name="Main" type="Node3D"] -[node name="Player" parent="." instance=ExtResource("1_2vsi6")] -transform = Transform3D(0.054514527, 0, -0.9985129, 0, 1, 0, 0.9985129, 0, 0.054514527, 1.1344104, -132.74933, 135.37988) +[node name="Player" parent="." node_paths=PackedStringArray("TutorialWeaponTarget") instance=ExtResource("1_2vsi6")] +transform = Transform3D(0.054514527, 0, -0.9985129, 0, 1, 0, 0.9985129, 0, 0.054514527, -15.285732, -78.24933, 121.65933) +collision_layer = 17 +TutorialWeaponTarget = NodePath("../PlacedTutorialWeapon/WeaponLocationTarget") [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_1bvp3") @@ -84,3 +91,26 @@ stream = ExtResource("10_eca4n") transform = Transform3D(0.9961947, 0, -0.08715573, 0, 1, 0, 0.08715573, 0, 0.9961947, -4.593, 1.618, 0.583) end_location = Vector3(-4.593, 116.11, 0.583) lift_time = 15.0 + +[node name="PlacedTutorialWeapon" type="MeshInstance3D" parent="."] +transform = Transform3D(-2, 3.019916e-07, 0, -3.019916e-07, -2, 0, 0, 0, 2, -17.904, -79.265, 145.317) +mesh = ExtResource("14_0ari0") + +[node name="SpotLight3D" type="SpotLight3D" parent="PlacedTutorialWeapon"] +transform = Transform3D(1, -1.509958e-07, 6.600236e-15, 0, -4.371139e-08, -1, 1.509958e-07, 1, -4.371139e-08, 0, -2.3931274, 0) +spot_range = 9.85 +spot_attenuation = 0.46 +spot_angle = 15.0 + +[node name="WeaponLocationTarget" type="Marker3D" parent="PlacedTutorialWeapon"] + +[node name="TutorialDoneArea" type="Area3D" parent="."] +transform = Transform3D(0.9961947, 0, -0.08715574, 0, 1, 0, 0.08715574, 0, 0.9961947, -17, -79, 125.5) +collision_layer = 0 +collision_mask = 16 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="TutorialDoneArea"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.7500105, 4, 0.7499695) +shape = SubResource("BoxShape3D_0ari0") + +[connection signal="body_entered" from="TutorialDoneArea" to="Player" method="OnTutorialDone"] diff --git a/player_controller/PlayerController.tscn b/player_controller/PlayerController.tscn index 71040b50..7172dc80 100644 --- a/player_controller/PlayerController.tscn +++ b/player_controller/PlayerController.tscn @@ -134,7 +134,7 @@ target_position = Vector3(0, -0.75, 0) [node name="MantleSystem" parent="." instance=ExtResource("8_qu4wy")] MantleEndLocationDistanceFromWall = 0.3 -MantleHeightCastStart = 1.5 +MantleHeightCastStart = 2.0 [node name="Bobbing" type="Node3D" parent="."] script = ExtResource("10_7wk1w") @@ -375,44 +375,6 @@ to = NodePath("../../AtLeastOneCharge") event = &"power_used" delay_in_seconds = "0.0" -[node name="WeaponState" type="Node" parent="StateChart/Root"] -script = ExtResource("26_infe6") -initial_state = NodePath("InHand") -metadata/_custom_type_script = "uid://c1vp0ojjvaby1" - -[node name="ToPlanted" type="Node" parent="StateChart/Root/WeaponState"] -script = ExtResource("28_n7qhm") -to = NodePath("../Planted") -event = &"plant_weapon" -delay_in_seconds = "0.0" - -[node name="ToHand" type="Node" parent="StateChart/Root/WeaponState"] -script = ExtResource("28_n7qhm") -to = NodePath("../InHand") -event = &"recover_weapond" -delay_in_seconds = "0.0" - -[node name="InHand" type="Node" parent="StateChart/Root/WeaponState"] -script = ExtResource("27_34snm") - -[node name="ToThrown" type="Node" parent="StateChart/Root/WeaponState/InHand"] -script = ExtResource("28_n7qhm") -to = NodePath("../../Flying") -event = &"throw" -delay_in_seconds = "0.0" - -[node name="Flying" type="Node" parent="StateChart/Root/WeaponState"] -script = ExtResource("27_34snm") - -[node name="ToPlanted" type="Node" parent="StateChart/Root/WeaponState/Flying"] -script = ExtResource("28_n7qhm") -to = NodePath("../../Planted") -event = &"plant_weapon" -delay_in_seconds = "0.0" - -[node name="Planted" type="Node" parent="StateChart/Root/WeaponState"] -script = ExtResource("27_34snm") - [node name="Movement" type="Node" parent="StateChart/Root"] script = ExtResource("26_infe6") initial_state = NodePath("Grounded") diff --git a/player_controller/Scripts/PlayerController.cs b/player_controller/Scripts/PlayerController.cs index 03027080..1976fae2 100644 --- a/player_controller/Scripts/PlayerController.cs +++ b/player_controller/Scripts/PlayerController.cs @@ -50,6 +50,8 @@ public partial class PlayerController : CharacterBody3D private Timer _timeScaleAimInAirTimer; private Timer _simpleDashCooldownTimer; private Timer _powerCooldownTimer; + + [Export] public Marker3D TutorialWeaponTarget; [ExportCategory("Movement")] [ExportGroup("Ground")] @@ -156,26 +158,22 @@ public partial class PlayerController : CharacterBody3D PlayerUi.SetNumberOfDashesLeft(value); } } - + public bool TutorialDone { get; set; } = false; + + private bool _canDashAirborne = true; private bool _isWallJumpAvailable = true; private bool _canDash = true; private bool _shouldMantleOnDashEnded = false; private StateChart _playerState; - private StateChartState _weaponInHand; private StateChartState _aiming; - private StateChartState _weaponThrown; - private StateChartState _actionHanging; private StateChartState _empowerOn; - private StateChartState _empowerOff; private StateChartState _powerExpired; private StateChartState _powerRecharging; private StateChartState _powerFull; private StateChartState _grounded; - private StateChartState _mantling; - private StateChartState _movHanging; private StateChartState _airborne; private StateChartState _coyoteEnabled; private StateChartState _simpleJump; @@ -184,13 +182,9 @@ public partial class PlayerController : CharacterBody3D private StateChartState _simpleDash; private StateChartState _poweredDash; private StateChartState _aimedDash; - private StateChartState _doubleJumpEnabled; - private StateChartState _onWall; private StateChartState _onWallHugCanceled; private StateChartState _onWallHugging; private StateChartState _onWallHanging; - private StateChartState _falling; - private StateChartState _to_weapon_dash; private Transition _onJumpFromWall; private Transition _onMegajumpFromWall; @@ -277,31 +271,22 @@ public partial class PlayerController : CharacterBody3D // State management _playerState = StateChart.Of(GetNode("StateChart")); - _weaponInHand = StateChartState.Of(GetNode("StateChart/Root/WeaponState/InHand")); - _weaponThrown = StateChartState.Of(GetNode("StateChart/Root/WeaponState/Flying")); _aiming = StateChartState.Of(GetNode("StateChart/Root/Aim/On")); _simpleDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/Dash")); _poweredDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/PoweredDash")); _aimedDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/AimedDash")); // _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging")); _empowerOn = StateChartState.Of(GetNode("StateChart/Root/Empower/On")); - _empowerOff = StateChartState.Of(GetNode("StateChart/Root/Empower/Off")); _powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired")); _powerRecharging = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/AtLeastOneCharge")); _powerFull = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Full")); _grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded")); - _mantling = StateChartState.Of(GetNode("StateChart/Root/Movement/Mantling")); - _movHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hanging")); _airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne")); _coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled")); _simpleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/SimpleJump")); _doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/DoubleJump")); _megaJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/MegaJump")); - _doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled")); - _falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling")); - _to_weapon_dash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/ToWeaponDash")); - _onWall = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall")); _onJumpFromWall = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/OnJump")); _onMegajumpFromWall = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/OnMegajump")); _onWallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hugging")); @@ -347,11 +332,11 @@ public partial class PlayerController : CharacterBody3D Stamina.SetSpeeds(WalkSpeed, WalkSpeed); EmpoweredActionsLeft = MaxNumberOfEmpoweredActions; + PlaceWeaponForTutorial(); /////////////////////////// // Signal setup /////////// /////////////////////////// - _weaponInHand.StateProcessing += HandleWeaponInHand; _aiming.StatePhysicsProcessing += HandleAiming; _aiming.StateEntered += OnAimingEntered; _aiming.StateExited += ResetTimeScale; @@ -363,8 +348,6 @@ public partial class PlayerController : CharacterBody3D _coyoteEnabled.StateEntered += StartCoyoteTime; _timeScaleAimInAirTimer.Timeout += ResetTimeScale; - - // _weaponThrown.StateEntered += OnWeaponThrown; _powerFull.StateEntered += StopPowerCooldown; _powerFull.StateExited += StartPowerCooldown; @@ -401,8 +384,12 @@ public partial class PlayerController : CharacterBody3D _onJumpFromWall.Taken += OnJumpFromWall; _onMegajumpFromWall.Taken += OnMegajumpFromWall; } - - private bool _canDashAirborne = true; + + public void OnTutorialDone(Node3D _) + { + TutorialDone = true; + GD.Print("tutorial done"); + } public void OnWallDetected() { @@ -833,6 +820,14 @@ public partial class PlayerController : CharacterBody3D { _playerState.SendEvent("dash_finished"); } + + public void PlaceWeaponForTutorial() + { + RemoveChild(WeaponRoot); + GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, WeaponRoot); + WeaponRoot.CallDeferred(Node3D.MethodName.SetGlobalPosition, TutorialWeaponTarget.GlobalPosition); + WeaponSystem.CallDeferred(WeaponSystem.MethodName.PlaceWeaponForTutorial, TutorialWeaponTarget.GlobalPosition); + } public void ThrowWeapon() { @@ -914,7 +909,7 @@ public partial class PlayerController : CharacterBody3D public bool CanPerformEmpoweredAction() { - return EmpoweredActionsLeft > 0; + return EmpoweredActionsLeft > 0 && TutorialDone; } public void PerformEmpoweredAction() @@ -949,13 +944,6 @@ public partial class PlayerController : CharacterBody3D _playerState.SendEvent("grounded"); } - // Regular processes - public void HandleWeaponInHand(float delta) - { - if (WeaponSystem.InHandState.Active) - RotateWeaponWithPlayer(); - } - /////////////////////////// // Stateless logic //////// /////////////////////////// @@ -1105,12 +1093,15 @@ public partial class PlayerController : CharacterBody3D CameraModifications((float) delta); HandleStairs((float) delta); - if (WeaponSystem.InHandState.Active && !_aiming.Active) + if (WeaponSystem.InHandState.Active) + RotateWeaponWithPlayer(); + + if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone) { DashIndicatorMesh.Visible = false; } - if (!WeaponSystem.InHandState.Active) + if (!WeaponSystem.InHandState.Active && TutorialDone) { DashIndicatorMesh.Visible = true; diff --git a/systems/mantle/mantle_system.tscn b/systems/mantle/mantle_system.tscn index 8737cbdf..b1283f07 100644 --- a/systems/mantle/mantle_system.tscn +++ b/systems/mantle/mantle_system.tscn @@ -6,6 +6,7 @@ height = 1.7 [sub_resource type="SphereShape3D" id="SphereShape3D_2oobp"] +radius = 0.75 [node name="MantleSystem" type="Node3D"] script = ExtResource("1_2oobp") diff --git a/systems/weapon/WeaponSystem.cs b/systems/weapon/WeaponSystem.cs index b7076805..59444011 100644 --- a/systems/weapon/WeaponSystem.cs +++ b/systems/weapon/WeaponSystem.cs @@ -81,6 +81,15 @@ public partial class WeaponSystem : RigidBody3D EmitSignalWeaponRetrieved(); } + public void PlaceWeaponForTutorial(Vector3 location) + { + _weaponState.SendEvent("plant"); + Freeze = true; + GlobalPosition = location; + PlantLocation = location; + Visible = false; + } + public void ThrowWeapon(Vector3 end, bool hasHit, Vector3 collisionLocation, Vector3 collisionNormal) { _weaponState.SendEvent("throw"); @@ -126,6 +135,7 @@ public partial class WeaponSystem : RigidBody3D _weaponState.SendEvent("recover"); Transform = _startTransform; Freeze = true; + Visible = true; } public override void _IntegrateForces(PhysicsDirectBodyState3D state) diff --git a/systems/weapon/weapon.tres b/systems/weapon/weapon.tres new file mode 100644 index 00000000..697ff4a1 --- /dev/null +++ b/systems/weapon/weapon.tres @@ -0,0 +1,13 @@ +[gd_resource type="CylinderMesh" load_steps=2 format=3 uid="uid://b7vt0nk2htpo4"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jv82r"] +use_z_clip_scale = true +z_clip_scale = 0.9 +use_fov_override = true +fov_override = 70.0 + +[resource] +material = SubResource("StandardMaterial3D_jv82r") +top_radius = 0.0 +bottom_radius = 0.05 +height = 1.0 diff --git a/systems/weapon/weapon.tscn b/systems/weapon/weapon.tscn index ec9bfd57..ea7a0fec 100644 --- a/systems/weapon/weapon.tscn +++ b/systems/weapon/weapon.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=13 format=3 uid="uid://ckm3d6k08a72u"] +[gd_scene load_steps=12 format=3 uid="uid://ckm3d6k08a72u"] [ext_resource type="Script" uid="uid://iii3wfto4t5b" path="res://systems/weapon/WeaponSystem.cs" id="1_csqwk"] [ext_resource type="PackedScene" uid="uid://dbe5f0p6lvqtr" path="res://systems/tween_queue/tween_queue_system.tscn" id="2_x1nha"] [ext_resource type="Script" uid="uid://couw105c3bde4" path="res://addons/godot_state_charts/state_chart.gd" id="3_5owyf"] +[ext_resource type="CylinderMesh" uid="uid://b7vt0nk2htpo4" path="res://systems/weapon/weapon.tres" id="3_svc06"] [ext_resource type="Script" uid="uid://jk2jm1g6q853" path="res://addons/godot_state_charts/compound_state.gd" id="4_svc06"] [ext_resource type="Script" uid="uid://cytafq8i1y8qm" path="res://addons/godot_state_charts/atomic_state.gd" id="5_m0v1h"] [ext_resource type="Script" uid="uid://cf1nsco3w0mf6" path="res://addons/godot_state_charts/transition.gd" id="6_jpdh0"] @@ -11,23 +12,12 @@ height = 1.0 radius = 0.1 -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5owyf"] -use_z_clip_scale = true -z_clip_scale = 0.9 -use_fov_override = true -fov_override = 70.0 - -[sub_resource type="CylinderMesh" id="CylinderMesh_x1nha"] -material = SubResource("StandardMaterial3D_5owyf") -top_radius = 0.0 -bottom_radius = 0.05 -height = 1.0 - [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_svc06"] render_priority = 1 transparency = 1 no_depth_test = true shading_mode = 0 +grow_amount = 0.1 stencil_mode = 3 stencil_flags = 1 stencil_compare = 5 @@ -62,7 +52,7 @@ shape = SubResource("CylinderShape3D_avini") [node name="Weapon" type="MeshInstance3D" parent="."] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) -mesh = SubResource("CylinderMesh_x1nha") +mesh = ExtResource("3_svc06") [node name="StateChart" type="Node" parent="."] script = ExtResource("3_5owyf") @@ -72,6 +62,12 @@ metadata/_custom_type_script = "uid://couw105c3bde4" script = ExtResource("4_svc06") initial_state = NodePath("InHand") +[node name="ToPlanted" type="Node" parent="StateChart/Root"] +script = ExtResource("6_jpdh0") +to = NodePath("../Planted") +event = &"plant" +delay_in_seconds = "0.0" + [node name="InHand" type="Node" parent="StateChart/Root"] script = ExtResource("5_m0v1h") @@ -90,12 +86,6 @@ to = NodePath("../../InHand") event = &"recover" delay_in_seconds = "0.0" -[node name="ToPlanted" type="Node" parent="StateChart/Root/Flying"] -script = ExtResource("6_jpdh0") -to = NodePath("../../Planted") -event = &"plant" -delay_in_seconds = "0.0" - [node name="Planted" type="Node" parent="StateChart/Root"] script = ExtResource("5_m0v1h") diff --git a/systems/weapon/weapon_tuto.tres b/systems/weapon/weapon_tuto.tres new file mode 100644 index 00000000..d79d3f89 --- /dev/null +++ b/systems/weapon/weapon_tuto.tres @@ -0,0 +1,11 @@ +[gd_resource type="CylinderMesh" load_steps=2 format=3 uid="uid://bhkbwvuft1bpg"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_f5qr4"] +z_clip_scale = 0.9 +fov_override = 70.0 + +[resource] +material = SubResource("StandardMaterial3D_f5qr4") +top_radius = 0.0 +bottom_radius = 0.05 +height = 1.0