Restore health fountain

This commit is contained in:
2026-01-12 20:26:05 -08:00
parent f13afc9fdc
commit 7e8826f143
5 changed files with 264 additions and 213 deletions

View File

@@ -12,34 +12,72 @@ public partial class Overworld : Node3D, IDungeonFloor
[Dependency] protected IGame Game => this.DependOn<IGame>();
[Dependency] protected IPlayer Player => this.DependOn<IPlayer>();
[Node] public Marker3D PlayerSpawnPoint { get; set; } = default!;
[Node] private Area3D Exit { get; set; } = default!;
[Node] private RescuedItems RescuedItems { get; set; } = default!;
[Node] private Area3D RestoreArea { get; set; } = default!;
public ImmutableList<IDungeonRoom> Rooms => [];
public bool FloorIsLoaded { get; set; }
private Timer RestoreTimer { get; set; }
public void InitializeDungeon()
{
Show();
Exit.AreaEntered += Exit_AreaEntered;
RescuedItems.SpawnRescuedItems();
FloorIsLoaded = true;
Show();
Exit.AreaEntered += Exit_AreaEntered;
RescuedItems.SpawnRescuedItems();
RestoreArea.AreaEntered += RestoreArea_AreaEntered;
RestoreArea.AreaExited += RestoreArea_AreaExited;
RestoreTimer = new Timer();
RestoreTimer.WaitTime = 0.3f;
RestoreTimer.Timeout += RestoreTimer_Timeout;
AddChild(RestoreTimer);
FloorIsLoaded = true;
}
private void RestoreTimer_Timeout()
{
if (!Player.HealthComponent.AtFullHealth)
Player.HealthComponent.Heal(1);
if (!Player.VTComponent.AtFullVT)
Player.VTComponent.Restore(1);
}
private void RestoreArea_AreaExited(Area3D area)
{
if (area.GetOwner() is IPlayer)
{
RestoreTimer.Stop();
Player.SetHealthTimerStatus(true);
}
}
private void RestoreArea_AreaEntered(Area3D area)
{
if (area.GetOwner() is IPlayer)
{
RestoreTimer.Start();
Player.SetHealthTimerStatus(false);
}
}
private void Exit_AreaEntered(Area3D area)
{
if (area.GetOwner() is IPlayer)
ExitReached();
if (area.GetOwner() is IPlayer)
ExitReached();
}
public void ExitReached() => Game.FloorExitReached();
public Transform3D GetPlayerSpawnPoint()
{
return PlayerSpawnPoint.GlobalTransform;
return PlayerSpawnPoint.GlobalTransform;
}
}

View File

@@ -1,10 +1,10 @@
[gd_scene load_steps=522 format=4 uid="uid://dvnc26rebk6o0"]
[gd_scene load_steps=523 format=4 uid="uid://dvnc26rebk6o0"]
[ext_resource type="Script" uid="uid://cuhfkyh3d7noa" path="res://src/map/dungeon/code/Overworld.cs" id="1_5hmt3"]
[ext_resource type="Texture2D" uid="uid://co6h8vyi11sl2" path="res://src/map/overworld/Models/Overworld_CLOUD_RINGS_INNER_63.png" id="2_g6b7b"]
[ext_resource type="AudioStream" uid="uid://ym4ur8a2qxhp" path="res://src/audio/amb/amb_perlin.wav" id="2_wbbo3"]
[ext_resource type="AudioStream" uid="uid://b7wxddjx3qw5o" path="res://src/audio/amb/amb_white_noise.wav" id="3_c2gp5"]
[ext_resource type="AudioStream" uid="uid://ddii3pi8x75xc" path="res://src/audio/amb/amb_beach.wav" id="3_pvi8n"]
[ext_resource type="AudioStream" uid="uid://dqmsaok6fyhe7" path="res://src/audio/amb/amb_perlin.wav" id="2_wbbo3"]
[ext_resource type="AudioStream" uid="uid://dl07vg00se7hd" path="res://src/audio/amb/amb_white_noise.wav" id="3_c2gp5"]
[ext_resource type="AudioStream" uid="uid://boypvgaweep8a" path="res://src/audio/amb/amb_beach.wav" id="3_pvi8n"]
[ext_resource type="Texture2D" uid="uid://w33fr6exryiy" path="res://src/map/overworld/Models/Overworld_CLOUD_RINGS_INNER_37.png" id="3_uyygh"]
[ext_resource type="Texture2D" uid="uid://dv10yaqvp3mub" path="res://src/map/overworld/Models/Overworld_CLOUD_RINGS_INNER_71.png" id="4_r8r3k"]
[ext_resource type="Shader" uid="uid://brhf7s3riyag5" path="res://src/map/map shaders/Metal.gdshader" id="5_d1qcb"]
@@ -10008,6 +10008,9 @@ shadow_mesh = SubResource("ArrayMesh_2djfl")
[sub_resource type="BoxShape3D" id="BoxShape3D_b53dq"]
size = Vector3(32.7888, 2.34912, 7.88136)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_yksd7"]
radius = 6.19775
[node name="Overworld" type="Node3D"]
script = ExtResource("1_5hmt3")
@@ -10728,5 +10731,14 @@ collision_mask = 256
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.28978, -2.1779, 7.74164)
shape = SubResource("BoxShape3D_b53dq")
[node name="RestoreArea" type="Area3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -293.713, 3.30221, 45.5386)
collision_layer = 256
collision_mask = 256
[node name="CollisionShape3D" type="CollisionShape3D" parent="RestoreArea"]
shape = SubResource("CylinderShape3D_yksd7")
[editable path="Node3D/Actors/Clalo"]
[editable path="Node3D/Actors/Caretaker of Saints"]