From e40bc38dcc17ebeb40722bedb94a6459e47b9aeb Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 27 Oct 2025 18:46:33 -0300 Subject: fix:bug loading deaths --- scripts/Entities/Actors/Actor.cs | 24 +++++++++++++++++++----- scripts/Entities/Actors/Enemy.cs | 4 ++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/Entities/Actors/Actor.cs b/scripts/Entities/Actors/Actor.cs index 71a32a5..c68cc2b 100644 --- a/scripts/Entities/Actors/Actor.cs +++ b/scripts/Entities/Actors/Actor.cs @@ -106,7 +106,16 @@ public partial class Actor : Entity, ISaveable EmitSignal(SignalName.HealthChanged, Hp, MaxHp); if (hp <= 0) { - Die(); + bool inLoading = true; + + // Se o ator morrer, porém não estiver em um SceneTree, + // Quer dizer que este ator já estava morto e estamos carregando + // um save. + if (IsInsideTree()) + { + inLoading = false; + } + Die(inLoading); } } } @@ -234,7 +243,7 @@ public partial class Actor : Entity, ISaveable Men = definition.Men; } - public virtual void Die() + public virtual void Die(bool inLoading) { //⠀⠀⠀⠀⢠⣤⣤⣤⢠⣤⣤⣤⣤⣄⢀⣠⣤⣤⣄⠀⠀⠀⢀⣠⣤⣤⣄⠀⣤⣤⠀⠀⣠⣤⣤⣤⣤⣤⡄⢠⣤⣤⣤⣄⠀⠀ //⠀⠀⠀⠀⠈⢹⣿⠉⠈⠉⣿⣿⠉⠉⢾⣿⣉⣉⠙⠀⠀⢀⣾⡟⠉⠉⣿⣧⢸⣿⡄⢠⣿⠏⣿⣿⣉⣉⡁⢸⣿⡏⢉⣿⡷⠀ @@ -273,14 +282,19 @@ public partial class Actor : Entity, ISaveable deathMessage = $"{DisplayName} morreu!"; } - MessageLogData.Instance.AddMessage(deathMessage); + if (!inLoading) + { + MessageLogData.Instance.AddMessage(deathMessage); + DisplayName = $"Restos mortais de {DisplayName}"; + + EmitSignal(SignalName.Died); + } + Texture = definition.deathTexture; BlocksMovement = false; Type = EntityType.CORPSE; - DisplayName = $"Restos mortais de {DisplayName}"; MapData.UnregisterBlockingEntity(this); - EmitSignal(SignalName.Died); } public new Dictionary GetSaveData() diff --git a/scripts/Entities/Actors/Enemy.cs b/scripts/Entities/Actors/Enemy.cs index 4994534..b4f5e68 100644 --- a/scripts/Entities/Actors/Enemy.cs +++ b/scripts/Entities/Actors/Enemy.cs @@ -52,11 +52,11 @@ public partial class Enemy : Actor, ISaveable } } - public override void Die() + public override void Die(bool inLoading) { Soul.QueueFree(); Soul = null; - base.Die(); + base.Die(inLoading); } public new Dictionary GetSaveData() -- cgit v1.2.3