summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-10-27 18:46:33 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-10-27 18:46:33 -0300
commite40bc38dcc17ebeb40722bedb94a6459e47b9aeb (patch)
treed23aa8a3e1cc2b792fda0b0173c6d58f51169e00
parentf4ed469fc9eaeebf39093fbf6601581cc10c6e2f (diff)
fix:bug loading deaths
-rw-r--r--scripts/Entities/Actors/Actor.cs24
-rw-r--r--scripts/Entities/Actors/Enemy.cs4
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<string, Variant> 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<string, Variant> GetSaveData()