summaryrefslogtreecommitdiff
path: root/scripts/Entities/Actors
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-18 12:06:59 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-18 12:06:59 -0300
commit5146895cf537dd69867da612abed5b4abaf805cd (patch)
tree70212352a07922b58db99ba2564f76ca072af200 /scripts/Entities/Actors
parenteacdd15612c70ff86f3446982c46a09272249936 (diff)
ME ELIMINE AAAAAAAAAAAAAAAAAAAAAAAAAAAA
Diffstat (limited to 'scripts/Entities/Actors')
-rw-r--r--scripts/Entities/Actors/AI/BaseAI.cs8
-rw-r--r--scripts/Entities/Actors/AI/HostileEnemyAI.cs32
-rw-r--r--scripts/Entities/Actors/Actor.cs22
-rw-r--r--scripts/Entities/Actors/ActorDefinition.cs2
-rw-r--r--scripts/Entities/Actors/Enemy.cs8
-rw-r--r--scripts/Entities/Actors/Inventory.cs8
-rw-r--r--scripts/Entities/Actors/Player.cs5
7 files changed, 41 insertions, 44 deletions
diff --git a/scripts/Entities/Actors/AI/BaseAI.cs b/scripts/Entities/Actors/AI/BaseAI.cs
index bdd1e61..3b9ae3e 100644
--- a/scripts/Entities/Actors/AI/BaseAI.cs
+++ b/scripts/Entities/Actors/AI/BaseAI.cs
@@ -20,13 +20,13 @@ public abstract partial class BaseAI : Node
/// Corpo controlado pela IA.
/// O corpo é a marionete da alma.
/// </summary>
- protected Actor Body { get; set; }
+ protected Actor body;
public override void _Ready()
{
base._Ready();
// Por padrão, a IA é filha do nó de seu corpo.
- Body = GetParent<Actor>();
+ body = GetParent<Actor>();
}
/// <summary>
@@ -42,12 +42,12 @@ public abstract partial class BaseAI : Node
/// </summary>
/// <param name="destination">Destino</param>
/// <returns>Vetor com vetores, passo a passo para chegar no destino.</returns>
- public Godot.Collections.Array<Vector2> GetPathTo(Vector2I destination)
+ protected Godot.Collections.Array<Vector2> GetPathTo(Vector2I destination)
{
// Arrays do Godot são muito mais confortáveis de manipular, então
// eu converto o Array do C# em um array do Godot antes de retornar o caminho.
Godot.Collections.Array<Vector2> list = [];
- Vector2[] path = Body.MapData.Pathfinder.GetPointPath(Body.GridPosition, destination);
+ Vector2[] path = body.MapData.Pathfinder.GetPointPath(body.GridPosition, destination);
list.AddRange(path);
return list;
}
diff --git a/scripts/Entities/Actors/AI/HostileEnemyAI.cs b/scripts/Entities/Actors/AI/HostileEnemyAI.cs
index 2f925c1..62e3d47 100644
--- a/scripts/Entities/Actors/AI/HostileEnemyAI.cs
+++ b/scripts/Entities/Actors/AI/HostileEnemyAI.cs
@@ -12,29 +12,29 @@ public partial class HostileEnemyAI : BaseAI
/// <summary>
/// Caminho até a última posição conhecida do jogador.
/// </summary>
- private Godot.Collections.Array<Vector2> Path { get; set; } = [];
+ private Godot.Collections.Array<Vector2> path = [];
public override void Perform()
{
// O alvo da IA sempre é o jogador.
- Player target = Body.MapData.Player;
+ Player target = body.MapData.Player;
// Vetor que parte do inimigo até o jogador.
- Vector2I offset = target.GridPosition - Body.GridPosition;
+ Vector2I offset = target.GridPosition - body.GridPosition;
// Distância entre o inimigo e o jogador. Leva em consideração somente
// um dos eixos.
- int distance = Grid.Distance(Body.GridPosition, target.GridPosition);
+ int distance = Grid.Distance(body.GridPosition, target.GridPosition);
// A ação executada no turno pode ser de ataque ou de movimento.
Action action;
// Só faz sentido atacar o jogador se o inimigo estiver visível.
- if (Body.MapData.GetTile(Body.GridPosition).IsInView)
+ if (body.MapData.GetTile(body.GridPosition).IsInView)
{
// Se o inimigo consegue ver que o jogador está morto,
// IT'S OVER.
if (!target.IsAlive)
{
- action = new WaitAction(Body);
+ action = new WaitAction(body);
action.Perform();
return;
}
@@ -42,7 +42,7 @@ public partial class HostileEnemyAI : BaseAI
// Se estiver do lado do jogador, ataque.
if (distance <= 1)
{
- action = new MeleeAction(Body, offset);
+ action = new MeleeAction(body, offset);
action.Perform();
// Executada a ação, acabamos nosso turno aqui.
return;
@@ -51,34 +51,34 @@ public partial class HostileEnemyAI : BaseAI
// Se o inimigo estiver visível para o jogador,
// consideramos que ele também consiga ver o jogador.
// Logo, atualizamos o caminho para a posição atual do jogador.
- Path = GetPathTo(target.GridPosition);
+ path = GetPathTo(target.GridPosition);
// O primeiro passo é a posição atual do inimigo, podemos remover.
- Path.RemoveAt(0);
+ path.RemoveAt(0);
}
// Se existir um caminho conhecido para o jogador.
- if (Path.Count > 0)
+ if (path.Count > 0)
{
// Pegamos o próximo passo para o destino.
- Vector2I destination = (Vector2I)Path[0];
+ Vector2I destination = (Vector2I)path[0];
// Se tiver o caminho estiver bloqueado, paramos o nosso turno aqui.
- if (Body.MapData.GetBlockingEntityAtPosition(destination) != null)
+ if (body.MapData.GetBlockingEntityAtPosition(destination) != null)
{
- action = new WaitAction(Body);
+ action = new WaitAction(body);
action.Perform();
return;
}
// Caso o contrário, criamos uma nova ação de movimentação e a executamos.
- action = new MovementAction(Body, destination - Body.GridPosition);
+ action = new MovementAction(body, destination - body.GridPosition);
action.Perform();
// Podemos remover o passo do caminho.
- Path.RemoveAt(0);
+ path.RemoveAt(0);
return;
}
// Senão, espere.
- action = new WaitAction(Body);
+ action = new WaitAction(body);
action.Perform();
return;
}
diff --git a/scripts/Entities/Actors/Actor.cs b/scripts/Entities/Actors/Actor.cs
index 7e228f8..ec00e30 100644
--- a/scripts/Entities/Actors/Actor.cs
+++ b/scripts/Entities/Actors/Actor.cs
@@ -16,6 +16,12 @@ public partial class Actor : Entity
private int hp;
private int energy;
+
+ /// <summary>
+ /// A definição do ator possui caracterísitcas padrões que definem
+ /// o ator em questão.
+ /// </summary>
+ private ActorDefinition definition;
#endregion
#region Constructors
@@ -77,7 +83,7 @@ public partial class Actor : Entity
/// <summary>
/// Taxa de recarga de energia.
/// </summary>
- public int Speed { get => Definition.Speed; }
+ public int Speed { get => definition.Speed; }
/// <summary>
/// HP máximo do ator.
@@ -142,16 +148,6 @@ public partial class Actor : Entity
/// </summary>
public int MpRegenPerTurn { get; private set; } = 5;
- /// <summary>
- /// A definição do ator possui caracterísitcas padrões que definem
- /// o ator em questão.
- /// </summary>
- private ActorDefinition Definition
- {
- get;
- set;
- }
-
public SpellBook SpellBook { get; private set; } = new();
#endregion
@@ -220,7 +216,7 @@ public partial class Actor : Entity
public virtual void SetDefinition(ActorDefinition definition)
{
base.SetDefinition(definition);
- Definition = definition;
+ this.definition = definition;
Type = definition.Type;
@@ -275,7 +271,7 @@ public partial class Actor : Entity
MessageLogData.Instance.AddMessage(deathMessage);
- Texture = Definition.deathTexture;
+ Texture = definition.deathTexture;
BlocksMovement = false;
Type = EntityType.CORPSE;
DisplayName = $"Restos mortais de {DisplayName}";
diff --git a/scripts/Entities/Actors/ActorDefinition.cs b/scripts/Entities/Actors/ActorDefinition.cs
index 5bd8073..bc34cb6 100644
--- a/scripts/Entities/Actors/ActorDefinition.cs
+++ b/scripts/Entities/Actors/ActorDefinition.cs
@@ -15,7 +15,7 @@ public partial class ActorDefinition : EntityDefinition
[ExportCategory("Mechanics")]
[Export]
- public int Speed { get; set; } = 10;
+ public int Speed = 10;
// Estatísticas padrão do ator.
[ExportCategory("Stats")]
diff --git a/scripts/Entities/Actors/Enemy.cs b/scripts/Entities/Actors/Enemy.cs
index c152a0b..d398176 100644
--- a/scripts/Entities/Actors/Enemy.cs
+++ b/scripts/Entities/Actors/Enemy.cs
@@ -10,9 +10,11 @@ namespace TheLegendOfGustav.Entities.Actors;
/// </summary>
public partial class Enemy : Actor
{
+ private EnemyDefinition definition;
+
public Enemy(Vector2I initialPosition, MapData map, EnemyDefinition definition) : base(initialPosition, map, definition)
{
- Definition = definition;
+ this.definition = definition;
SetDefinition(definition);
}
@@ -21,8 +23,6 @@ public partial class Enemy : Actor
/// </summary>
public BaseAI Soul { get; private set; }
- private EnemyDefinition Definition { get; set; }
-
/// <summary>
/// Além de definir as características gerais de um ator,
/// também define qual IA utilizar.
@@ -31,7 +31,7 @@ public partial class Enemy : Actor
public void SetDefinition(EnemyDefinition definition)
{
// Definimos as características do ator.
- base.SetDefinition(Definition);
+ base.SetDefinition(this.definition);
// Definimos qual IA utilizar.
switch (definition.AI)
diff --git a/scripts/Entities/Actors/Inventory.cs b/scripts/Entities/Actors/Inventory.cs
index f65dc59..057316a 100644
--- a/scripts/Entities/Actors/Inventory.cs
+++ b/scripts/Entities/Actors/Inventory.cs
@@ -7,27 +7,27 @@ namespace TheLegendOfGustav.Entities.Actors;
public partial class Inventory(int capacity) : Node
{
- private Player Player { get; set; }
+ private Player player;
public int Capacity { get; private set; } = capacity;
public Godot.Collections.Array<ConsumableItem> Items { get; private set; } = [];
public override void _Ready()
{
base._Ready();
- Player = GetParent<Player>();
+ player = GetParent<Player>();
}
public void Drop(ConsumableItem item)
{
Items.Remove(item);
- MapData data = Player.MapData;
+ MapData data = player.MapData;
data.InsertEntity(item);
data.EmitSignal(MapData.SignalName.EntityPlaced, item);
item.MapData = data;
- item.GridPosition = Player.GridPosition;
+ item.GridPosition = player.GridPosition;
MessageLogData.Instance.AddMessage($"Você descarta {item.DisplayName}.");
}
diff --git a/scripts/Entities/Actors/Player.cs b/scripts/Entities/Actors/Player.cs
index 7fd80d4..d6fedb9 100644
--- a/scripts/Entities/Actors/Player.cs
+++ b/scripts/Entities/Actors/Player.cs
@@ -9,13 +9,14 @@ namespace TheLegendOfGustav.Entities.Actors;
[GlobalClass]
public partial class Player : Actor
{
+ private PlayerDefinition definition;
+
public Player(Vector2I initialPosition, MapData map, PlayerDefinition definition) : base(initialPosition, map, definition)
{
- Definition = definition;
+ this.definition = definition;
SetDefinition(definition);
}
- private PlayerDefinition Definition { get; set; }
public Inventory Inventory { get; private set; }
public void SetDefinition(PlayerDefinition definition)