From e050d200717aa1d5eb24d4d7b3e40ef171afb488 Mon Sep 17 00:00:00 2001 From: Zenny Date: Wed, 5 Mar 2025 19:11:31 -0800 Subject: [PATCH] Loading works Debug pickup --- src/Main.tscn | 1 + src/app/App.cs | 9 ++---- src/app/App.tscn | 32 +++++++++---------- src/app/state/AppLogic.Data.cs.uid | 1 + src/app/state/states/AppLogic.State.InGame.cs | 2 +- .../state/states/AppLogic.State.InGame.cs.uid | 1 + .../states/AppLogic.State.LeavingMenu.cs.uid | 1 + .../states/AppLogic.State.LoadingSaveFile.cs | 1 + .../AppLogic.State.LoadingSaveFile.cs.uid | 1 + .../states/AppLogic.State.MainMenu.cs.uid | 1 + .../states/AppLogic.State.SplashScreen.cs.uid | 1 + src/game/Game.cs | 17 +++------- src/game/Game.tscn | 1 + src/game/GameLogic.g.puml | 1 + src/game/IGame.cs | 4 --- .../states/GameLogic.State.MenuBackdrop.cs | 13 ++++++-- .../GameLogic.State.MenuBackdrop.cs.uid | 1 + src/items/EffectService.cs | 4 +-- src/items/dropped/DroppedItem.cs | 18 +++++------ src/items/dropped/DroppedItem.tscn | 13 +++++++- src/map/Map.cs | 14 ++++++-- src/map/dungeon/code/DungeonFloor.cs | 2 +- src/map/dungeon/code/Floor0.cs | 4 +-- src/map/dungeon/floors/Floor00.tscn | 4 --- src/menu/splash/Splash.tscn | 30 ++++++++--------- src/player/IPlayer.cs | 2 +- src/player/Player.cs | 27 +++++++++------- src/player/Player.tscn | 4 +-- src/ui/in_game_ui/InGameUI.tscn | 4 +-- src/ui/player_ui/PlayerInfoUI.tscn | 2 +- 30 files changed, 120 insertions(+), 96 deletions(-) create mode 100644 src/app/state/AppLogic.Data.cs.uid create mode 100644 src/app/state/states/AppLogic.State.InGame.cs.uid create mode 100644 src/app/state/states/AppLogic.State.LeavingMenu.cs.uid create mode 100644 src/app/state/states/AppLogic.State.LoadingSaveFile.cs.uid create mode 100644 src/app/state/states/AppLogic.State.MainMenu.cs.uid create mode 100644 src/app/state/states/AppLogic.State.SplashScreen.cs.uid create mode 100644 src/game/state/states/GameLogic.State.MenuBackdrop.cs.uid diff --git a/src/Main.tscn b/src/Main.tscn index 497e0027..5b308403 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -3,4 +3,5 @@ [ext_resource type="Script" uid="uid://cck757iieiyj5" path="res://src/Main.cs" id="1_prpoe"] [node name="Node" type="Node"] +process_mode = 3 script = ExtResource("1_prpoe") diff --git a/src/app/App.cs b/src/app/App.cs index dc79ab81..3b47b773 100644 --- a/src/app/App.cs +++ b/src/app/App.cs @@ -78,7 +78,6 @@ public partial class App : CanvasLayer, IApp // Load everything while we're showing a black screen, then fade in. HideMenus(); Menu.Show(); - Game.Show(); FadeInFromBlack(); Menu.NewGameButton.GrabFocus(); @@ -136,18 +135,14 @@ public partial class App : CanvasLayer, IApp public void OnAnimationFinished(StringName animation) { - // There's only two animations :) - // We don't care what state we're in — we just tell the current state what's - // happened and it will do the right thing. - if (animation == "fade_in") { - AppLogic.Input(new AppLogic.Input.FadeInFinished()); + AppLogic.Input(new FadeInFinished()); BlankScreen.Hide(); return; } - AppLogic.Input(new AppLogic.Input.FadeOutFinished()); + AppLogic.Input(new FadeOutFinished()); } public void OnExitTree() diff --git a/src/app/App.tscn b/src/app/App.tscn index c14b7873..11b4ea1a 100644 --- a/src/app/App.tscn +++ b/src/app/App.tscn @@ -4,21 +4,6 @@ [ext_resource type="PackedScene" uid="uid://rfvnddfqufho" path="res://src/menu/Menu.tscn" id="2_kvwo1"] [ext_resource type="PackedScene" uid="uid://bd0p761qakisw" path="res://src/menu/splash/Splash.tscn" id="3_3st5l"] -[sub_resource type="Animation" id="Animation_1uiag"] -resource_name = "fade_in" -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("BlankScreenControl/BlankScreen:color") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 1), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(0.270588, 0, 0, 1), Color(0, 0, 0, 0)] -} - [sub_resource type="Animation" id="Animation_3st5l"] length = 0.001 tracks/0/type = "value" @@ -34,6 +19,21 @@ tracks/0/keys = { "values": [Color(0, 0, 0, 1)] } +[sub_resource type="Animation" id="Animation_1uiag"] +resource_name = "fade_in" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("BlankScreenControl/BlankScreen:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)] +} + [sub_resource type="Animation" id="Animation_v0mgf"] resource_name = "fade_out" tracks/0/type = "value" @@ -46,7 +46,7 @@ tracks/0/keys = { "times": PackedFloat32Array(0, 1), "transitions": PackedFloat32Array(1, 1), "update": 0, -"values": [Color(0, 0, 0, 0), Color(0, 0, 0.454902, 1)] +"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] } [sub_resource type="AnimationLibrary" id="AnimationLibrary_3st5l"] diff --git a/src/app/state/AppLogic.Data.cs.uid b/src/app/state/AppLogic.Data.cs.uid new file mode 100644 index 00000000..79e3b2b9 --- /dev/null +++ b/src/app/state/AppLogic.Data.cs.uid @@ -0,0 +1 @@ +uid://cbqvl36d7foae diff --git a/src/app/state/states/AppLogic.State.InGame.cs b/src/app/state/states/AppLogic.State.InGame.cs index fa8275ba..9831180a 100644 --- a/src/app/state/states/AppLogic.State.InGame.cs +++ b/src/app/state/states/AppLogic.State.InGame.cs @@ -15,8 +15,8 @@ public partial class AppLogic this.OnEnter(() => { - Get().OnEnterGame(); Output(new Output.ShowGame()); + Get().OnEnterGame(); }); this.OnExit(() => Output(new Output.HideGame())); diff --git a/src/app/state/states/AppLogic.State.InGame.cs.uid b/src/app/state/states/AppLogic.State.InGame.cs.uid new file mode 100644 index 00000000..cea3173d --- /dev/null +++ b/src/app/state/states/AppLogic.State.InGame.cs.uid @@ -0,0 +1 @@ +uid://ckb88dvtckagu diff --git a/src/app/state/states/AppLogic.State.LeavingMenu.cs.uid b/src/app/state/states/AppLogic.State.LeavingMenu.cs.uid new file mode 100644 index 00000000..384dfea9 --- /dev/null +++ b/src/app/state/states/AppLogic.State.LeavingMenu.cs.uid @@ -0,0 +1 @@ +uid://du7y6o0h004sm diff --git a/src/app/state/states/AppLogic.State.LoadingSaveFile.cs b/src/app/state/states/AppLogic.State.LoadingSaveFile.cs index bfb4f946..747b907c 100644 --- a/src/app/state/states/AppLogic.State.LoadingSaveFile.cs +++ b/src/app/state/states/AppLogic.State.LoadingSaveFile.cs @@ -14,6 +14,7 @@ public partial class AppLogic { this.OnEnter(() => Output(new Output.StartLoadingSaveFile())); } + public Transition On(in Input.SaveFileLoaded input) => To(); } } diff --git a/src/app/state/states/AppLogic.State.LoadingSaveFile.cs.uid b/src/app/state/states/AppLogic.State.LoadingSaveFile.cs.uid new file mode 100644 index 00000000..eea01249 --- /dev/null +++ b/src/app/state/states/AppLogic.State.LoadingSaveFile.cs.uid @@ -0,0 +1 @@ +uid://b5j2df20jd05i diff --git a/src/app/state/states/AppLogic.State.MainMenu.cs.uid b/src/app/state/states/AppLogic.State.MainMenu.cs.uid new file mode 100644 index 00000000..9719320d --- /dev/null +++ b/src/app/state/states/AppLogic.State.MainMenu.cs.uid @@ -0,0 +1 @@ +uid://b5ehfb8l8u2fy diff --git a/src/app/state/states/AppLogic.State.SplashScreen.cs.uid b/src/app/state/states/AppLogic.State.SplashScreen.cs.uid new file mode 100644 index 00000000..8e595471 --- /dev/null +++ b/src/app/state/states/AppLogic.State.SplashScreen.cs.uid @@ -0,0 +1 @@ +uid://dxbrwt7jduxu8 diff --git a/src/game/Game.cs b/src/game/Game.cs index e8fb5523..c0cb9cdc 100644 --- a/src/game/Game.cs +++ b/src/game/Game.cs @@ -188,8 +188,8 @@ public partial class Game : Node3D, IGame GameBinding .Handle((in GameLogic.Output.StartGame _) => { - InGameUI.Show(); GameRepo.Resume(); + InGameUI.Show(); }) .Handle((in GameLogic.Output.GoToOverworld _) => { @@ -218,7 +218,7 @@ public partial class Game : Node3D, IGame .Handle((in GameLogic.Output.ExitLostScreen _) => { DeathMenu.FadeOut(); }) .Handle((in GameLogic.Output.SaveGame _) => { - Save(); + SaveFile.Save(); AppRepo.OnExitGame(); GetTree().Quit(); // Back to title screen @@ -248,16 +248,6 @@ public partial class Game : Node3D, IGame _effectService = new EffectService(this, Player); } - public void Save() - { - SaveFile.Save(); - } - - public void Load() - { - SaveFile.Load(); - } - public void LoadExistingGame() { SaveFile.Load() @@ -493,6 +483,9 @@ public partial class Game : Node3D, IGame GameLogic.Input(new GameLogic.Input.PauseMenuTransitioned()); } + public void OnStart() => + GameLogic.Input(new GameLogic.Input.StartGame()); + private void FinishedLoadingSaveFile() { EmitSignal(SignalName.SaveFileLoaded); diff --git a/src/game/Game.tscn b/src/game/Game.tscn index d294a516..9a2d6318 100644 --- a/src/game/Game.tscn +++ b/src/game/Game.tscn @@ -62,6 +62,7 @@ wait_time = 30.0 [node name="InGameUI" parent="." instance=ExtResource("5_lxtnp")] unique_name_in_owner = true +visible = false [node name="InGameAudio" parent="." instance=ExtResource("6_qc71l")] unique_name_in_owner = true diff --git a/src/game/GameLogic.g.puml b/src/game/GameLogic.g.puml index ae57eb66..741ae88c 100644 --- a/src/game/GameLogic.g.puml +++ b/src/game/GameLogic.g.puml @@ -18,6 +18,7 @@ GameJamDungeon_GameLogic_State_FloorClearedDecisionState --> GameJamDungeon_Game GameJamDungeon_GameLogic_State_FloorClearedDecisionState --> GameJamDungeon_GameLogic_State_Playing : HideFloorClearMenu GameJamDungeon_GameLogic_State_FloorClearedDecisionState --> GameJamDungeon_GameLogic_State_Playing : SaveGame GameJamDungeon_GameLogic_State_InventoryOpened --> GameJamDungeon_GameLogic_State_Playing : CloseInventory +GameJamDungeon_GameLogic_State_MenuBackdrop --> GameJamDungeon_GameLogic_State_MenuBackdrop : Initialize GameJamDungeon_GameLogic_State_MenuBackdrop --> GameJamDungeon_GameLogic_State_Playing : StartGame GameJamDungeon_GameLogic_State_MinimapOpen --> GameJamDungeon_GameLogic_State_Playing : MiniMapButtonReleased GameJamDungeon_GameLogic_State_Paused --> GameJamDungeon_GameLogic_State_Resuming : UnpauseGame diff --git a/src/game/IGame.cs b/src/game/IGame.cs index b5120f19..5271731a 100644 --- a/src/game/IGame.cs +++ b/src/game/IGame.cs @@ -41,9 +41,5 @@ public interface IGame : IProvide, IProvide, IProvid public void EnemyDefeated(Vector3 defeatedLocation, EnemyStatResource enemyStatResource); - public void Save(); - - public void Load(); - public void TogglePause(); } diff --git a/src/game/state/states/GameLogic.State.MenuBackdrop.cs b/src/game/state/states/GameLogic.State.MenuBackdrop.cs index 31cbc21d..ee60a087 100644 --- a/src/game/state/states/GameLogic.State.MenuBackdrop.cs +++ b/src/game/state/states/GameLogic.State.MenuBackdrop.cs @@ -7,7 +7,7 @@ public partial class GameLogic public partial record State { [Meta] - public partial record MenuBackdrop : State, IGet + public partial record MenuBackdrop : State, IGet, IGet { public MenuBackdrop() { @@ -17,7 +17,16 @@ public partial class GameLogic public void OnGameEntered() => Input(new Input.StartGame()); - public Transition On(in Input.StartGame input) => To(); + public Transition On(in Input.StartGame input) + { + Get().LoadMap(); + return To(); + } + + public Transition On(in Input.Initialize input) + { + return ToSelf(); + } } } } diff --git a/src/game/state/states/GameLogic.State.MenuBackdrop.cs.uid b/src/game/state/states/GameLogic.State.MenuBackdrop.cs.uid new file mode 100644 index 00000000..6a78b899 --- /dev/null +++ b/src/game/state/states/GameLogic.State.MenuBackdrop.cs.uid @@ -0,0 +1 @@ +uid://lwjsht36v6ut diff --git a/src/items/EffectService.cs b/src/items/EffectService.cs index 67edfb97..0527b9e6 100644 --- a/src/items/EffectService.cs +++ b/src/items/EffectService.cs @@ -189,7 +189,7 @@ namespace GameJamDungeon.src.items var randomRoom = roomsGodotCollection.PickRandom(); var spawnPoint = randomRoom.PlayerSpawn; _game.ToggleInventory(); - player.TeleportPlayer(spawnPoint.GlobalPosition); + player.TeleportPlayer(spawnPoint.Transform); } public void ChangeAffinity(ThrowableItem throwableItem) @@ -207,7 +207,7 @@ namespace GameJamDungeon.src.items { var exitRoom = _game.CurrentFloor.Rooms.OfType().Single(); if (exitRoom.PlayerDiscoveredRoom) - player.TeleportPlayer(exitRoom.PlayerSpawn.GlobalPosition); + player.TeleportPlayer(exitRoom.PlayerSpawn.Transform); } public void WarpToExit(IEnemy enemy) diff --git a/src/items/dropped/DroppedItem.cs b/src/items/dropped/DroppedItem.cs index b8b2e179..0c0ddd32 100644 --- a/src/items/dropped/DroppedItem.cs +++ b/src/items/dropped/DroppedItem.cs @@ -21,27 +21,34 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem [Node] private Sprite2D Sprite { get; set; } = default!; + [Node] private Area3D Pickup { get; set; } = default!; + public InventoryItem Item { get; set; } public void OnResolved() { ContactMonitor = true; - BodyEntered += DroppedItem_BodyEntered; Sprite.Texture = Item.ItemStats.Texture; } public async void Drop() { AddCollisionExceptionWith((Node)Player); + Pickup.Monitorable = false; + Pickup.Monitoring = false; GlobalPosition = Player.CurrentPosition + Vector3.Up; ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * 5.0f); await ToSignal(GetTree().CreateTimer(1), "timeout"); RemoveCollisionExceptionWith((Node)Player); + Pickup.Monitorable = true; + Pickup.Monitoring = true; } public void RescueItem() { ContactMonitor = false; + Pickup.Monitorable = false; + Pickup.Monitoring = false; PlayRescueAnimation(); Game.RescuedItems.Items.Add(Item); } @@ -75,13 +82,4 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem shaderMaterial.SetShaderParameter("reverse", shaderValue); } - private void DroppedItem_BodyEntered(Node body) - { - if (body is IPlayer player) - { - var isAdded = player.Inventory.TryAdd(Item); - if (isAdded) - QueueFree(); - } - } } diff --git a/src/items/dropped/DroppedItem.tscn b/src/items/dropped/DroppedItem.tscn index 93ab8be0..01c716d9 100644 --- a/src/items/dropped/DroppedItem.tscn +++ b/src/items/dropped/DroppedItem.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://brq11lswpqxei"] +[gd_scene load_steps=10 format=3 uid="uid://brq11lswpqxei"] [ext_resource type="Script" uid="uid://c2sps6uamyyw2" path="res://src/items/dropped/DroppedItem.cs" id="1_67jk4"] [ext_resource type="Texture2D" uid="uid://mi70lolgtf3n" path="res://src/items/throwable/textures/GEOMANCER-DICE.png" id="2_cu1v3"] @@ -47,6 +47,9 @@ _data = { [sub_resource type="ViewportTexture" id="ViewportTexture_x5q15"] viewport_path = NodePath("Sprite3D/SubViewportContainer/SubViewport") +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_eat5q"] +radius = 0.47 + [node name="DroppedItem" type="RigidBody3D"] collision_layer = 1024 collision_mask = 5 @@ -92,3 +95,11 @@ scale = Vector2(0.1, 0.1) texture = ExtResource("2_cu1v3") centered = false offset = Vector2(2000, 2000) + +[node name="Pickup" type="Area3D" parent="."] +unique_name_in_owner = true +collision_layer = 4 +collision_mask = 0 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"] +shape = SubResource("CapsuleShape3D_eat5q") diff --git a/src/map/Map.cs b/src/map/Map.cs index b5aa6b1f..0205c859 100644 --- a/src/map/Map.cs +++ b/src/map/Map.cs @@ -10,6 +10,8 @@ namespace GameJamDungeon; public interface IMap : INode3D, IProvide> { + public void LoadMap(); + public List FloorScenes { get; } public IDungeonFloor CurrentFloor { get; } @@ -49,7 +51,7 @@ public partial class Map : Node3D, IMap public void OnResolved() { - FloorScenes = new List(); + FloorScenes = []; MapChunk = new SaveChunk( onSave: (chunk) => new MapData() @@ -65,11 +67,19 @@ public partial class Map : Node3D, IMap GameChunk.AddChunk(MapChunk); this.Provide(); + } + public void LoadMap() + { foreach (var floor in _floors) FloorScenes.Add(floor.ResourcePath); LoadFloor(); + CurrentFloor.InitializeDungeon(); + var transform = GetPlayerSpawnPosition(); + Player.TeleportPlayer(transform); + CurrentFloor.FloorIsLoaded = true; + Game.NextFloorLoaded(); } public void SpawnNextFloor() @@ -79,7 +89,7 @@ public partial class Map : Node3D, IMap LoadFloor(); CurrentFloor.InitializeDungeon(); var transform = GetPlayerSpawnPosition(); - Player.TeleportPlayer(new Vector3(transform.Origin.X, -1.75f, transform.Origin.Z)); + Player.TeleportPlayer(transform); CurrentFloor.FloorIsLoaded = true; Game.NextFloorLoaded(); } diff --git a/src/map/dungeon/code/DungeonFloor.cs b/src/map/dungeon/code/DungeonFloor.cs index 2e3d8753..7b35f6c8 100644 --- a/src/map/dungeon/code/DungeonFloor.cs +++ b/src/map/dungeon/code/DungeonFloor.cs @@ -33,7 +33,7 @@ namespace GameJamDungeon DungeonGenerator.EmitSignal("done_generating"); } - public Transform3D GetPlayerSpawnPoint() => _playerSpawnPoint; + public Transform3D GetPlayerSpawnPoint() => new Transform3D(_playerSpawnPoint.Basis, new Vector3(_playerSpawnPoint.Origin.X, -1.75f, _playerSpawnPoint.Origin.Z)); private Transform3D RandomizePlayerSpawnPoint() { diff --git a/src/map/dungeon/code/Floor0.cs b/src/map/dungeon/code/Floor0.cs index 23ed2bd7..5af66c34 100644 --- a/src/map/dungeon/code/Floor0.cs +++ b/src/map/dungeon/code/Floor0.cs @@ -30,6 +30,6 @@ public partial class Floor0 : Node3D, IDungeonFloor private void Exit_AreaEntered(Area3D area) => ExitReached(); public void ExitReached() => Game.FloorExitReached(); - public void InitializeDungeon() => throw new System.NotImplementedException(); - public Transform3D GetPlayerSpawnPoint() => throw new System.NotImplementedException(); + public void InitializeDungeon() { return; } + public Transform3D GetPlayerSpawnPoint() { return new Transform3D(PlayerSpawnPoint.Basis, new Vector3(PlayerSpawnPoint.GlobalPosition.X, -3, PlayerSpawnPoint.GlobalPosition.Z)); } } diff --git a/src/map/dungeon/floors/Floor00.tscn b/src/map/dungeon/floors/Floor00.tscn index b46a6868..5cf05065 100644 --- a/src/map/dungeon/floors/Floor00.tscn +++ b/src/map/dungeon/floors/Floor00.tscn @@ -896,7 +896,3 @@ shape = SubResource("BoxShape3D_db2o3") [node name="Camera3D" type="Camera3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.00384, 1.80761, 11.3571) - -[node name="CSGBox3D" type="CSGBox3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.22872, 0) -size = Vector3(1, 1.7, 1) diff --git a/src/menu/splash/Splash.tscn b/src/menu/splash/Splash.tscn index ec11fcf7..1504f66d 100644 --- a/src/menu/splash/Splash.tscn +++ b/src/menu/splash/Splash.tscn @@ -2,6 +2,21 @@ [ext_resource type="Script" uid="uid://cl3shd6l7frmg" path="res://src/menu/splash/Splash.cs" id="1_7ivmr"] +[sub_resource type="Animation" id="Animation_jiqgw"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} + [sub_resource type="Animation" id="Animation_7ivmr"] resource_name = "intro" length = 3.0 @@ -18,21 +33,6 @@ tracks/0/keys = { "values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)] } -[sub_resource type="Animation" id="Animation_jiqgw"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("ColorRect:modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Color(1, 1, 1, 1)] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_jiqgw"] _data = { &"RESET": SubResource("Animation_jiqgw"), diff --git a/src/player/IPlayer.cs b/src/player/IPlayer.cs index 0f920d8e..cfaa9aea 100644 --- a/src/player/IPlayer.cs +++ b/src/player/IPlayer.cs @@ -25,7 +25,7 @@ public interface IPlayer : IKillable, IProvide> public void Move(float delta); - public void TeleportPlayer(Vector3 newPosition); + public void TeleportPlayer(Transform3D newTransform); public IDungeonRoom GetCurrentRoom(); diff --git a/src/player/Player.cs b/src/player/Player.cs index 1f6f6906..30573c2d 100644 --- a/src/player/Player.cs +++ b/src/player/Player.cs @@ -160,6 +160,9 @@ public partial class Player : CharacterBody3D, IPlayer Equip(defaultArmor); HealthTimer.WaitTime = _healthTimerWaitTime; + HealthTimer.Timeout += OnHealthTimerTimeout; + Hitbox.AreaEntered += Hitbox_AreaEntered; + CollisionDetector.AreaEntered += CollisionDetector_AreaEntered; } public void OnResolved() @@ -211,9 +214,6 @@ public partial class Player : CharacterBody3D, IPlayer PlayerLogic.Start(); this.Provide(); - HealthTimer.Timeout += OnHealthTimerTimeout; - Hitbox.AreaEntered += Hitbox_AreaEntered; - CollisionDetector.AreaEntered += CollisionDetector_AreaEntered; } private void CollisionDetector_AreaEntered(Area3D area) @@ -229,6 +229,17 @@ public partial class Player : CharacterBody3D, IPlayer else Game.AnnounceMessageOnMainScreen($"Could not pick up {inventoryItem.ItemName}."); } + if (area.GetParent() is DroppedItem droppedItem) + { + var isAdded = Inventory.TryAdd(droppedItem.Item); + if (isAdded) + { + Game.AnnounceMessageOnMainScreen($"{droppedItem.Item.ItemName} picked up."); + droppedItem.QueueFree(); + } + else + Game.AnnounceMessageOnMainScreen($"Could not pick up {droppedItem.Item.ItemName}."); + } } public void OnReady() @@ -337,9 +348,9 @@ public partial class Player : CharacterBody3D, IPlayer MoveAndSlide(); } - public void TeleportPlayer(Vector3 newPosition) + public void TeleportPlayer(Transform3D newTransform) { - GlobalPosition = newPosition; + Transform = newTransform; } public void TakeDamage(double damage, ElementType elementType, bool isCriticalHit = false) @@ -389,12 +400,6 @@ public partial class Player : CharacterBody3D, IPlayer if (@event.IsActionPressed(GameInputs.Attack)) Attack(); - - if (@event.IsActionPressed(GameInputs.Save)) - Game.Save(); - - if (@event.IsActionPressed(GameInputs.Load)) - Game.Load(); } public void OnPhysicsProcess(double delta) diff --git a/src/player/Player.tscn b/src/player/Player.tscn index 38d37cc3..9334e660 100644 --- a/src/player/Player.tscn +++ b/src/player/Player.tscn @@ -38,7 +38,7 @@ radius = 1.0 [sub_resource type="BoxShape3D" id="BoxShape3D_wedu3"] [sub_resource type="BoxShape3D" id="BoxShape3D_hs4wf"] -size = Vector3(1.94531, 3.38623, 2.35425) +size = Vector3(1.94531, 3.38623, 1.50671) [sub_resource type="Animation" id="Animation_hcjph"] length = 0.001 @@ -495,7 +495,7 @@ collision_layer = 452 collision_mask = 452 [node name="CollisionShape3D" type="CollisionShape3D" parent="CollisionDetector"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0479561, 0.509249, -0.675098) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0479561, 0.509249, -0.25133) shape = SubResource("BoxShape3D_hs4wf") [node name="Camera3D" type="Camera3D" parent="."] diff --git a/src/ui/in_game_ui/InGameUI.tscn b/src/ui/in_game_ui/InGameUI.tscn index 31319792..00cca250 100644 --- a/src/ui/in_game_ui/InGameUI.tscn +++ b/src/ui/in_game_ui/InGameUI.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=7 format=3 uid="uid://b1muxus5qdbeu"] -[ext_resource type="Script" path="res://src/ui/in_game_ui/InGameUI.cs" id="1_sc13i"] +[ext_resource type="Script" uid="uid://dlq2mkhl4pe7a" path="res://src/ui/in_game_ui/InGameUI.cs" id="1_sc13i"] [ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="2_6sfje"] [ext_resource type="PackedScene" uid="uid://dlj8qdg1c5048" path="res://src/inventory_menu/InventoryMenu.tscn" id="3_4vcdl"] [ext_resource type="PackedScene" uid="uid://dxl8il8f13c2x" path="res://src/ui/player_ui/PlayerInfoUI.tscn" id="4_46s5l"] [ext_resource type="PackedScene" uid="uid://bea2waybmgd6u" path="res://src/ui/teleport_prompt/UseTeleportPrompt.tscn" id="5_h1hgq"] -[ext_resource type="Script" path="res://src/utils/FpsCounter.cs" id="7_c6o8j"] +[ext_resource type="Script" uid="uid://dj6oqler47dqf" path="res://src/utils/FpsCounter.cs" id="7_c6o8j"] [node name="InGameUI" type="Control"] process_mode = 3 diff --git a/src/ui/player_ui/PlayerInfoUI.tscn b/src/ui/player_ui/PlayerInfoUI.tscn index b24a79f2..7cf138b6 100644 --- a/src/ui/player_ui/PlayerInfoUI.tscn +++ b/src/ui/player_ui/PlayerInfoUI.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://dxl8il8f13c2x"] [ext_resource type="Texture2D" uid="uid://hg2kraa5nrnl" path="res://src/ui/textures/blank level symbol.png" id="1_78qrq"] -[ext_resource type="Script" path="res://src/ui/player_ui/PlayerInfoUI.cs" id="1_d8yyu"] +[ext_resource type="Script" uid="uid://b65cbirtijlii" path="res://src/ui/player_ui/PlayerInfoUI.cs" id="1_d8yyu"] [ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="2_aa7fx"] [ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="3_xdjh1"]