Hello,

I'm doing a Tactical RPG, and don't know if my architecture is right or not:
I have Board, Characters and Attacks nodes.

Attacks have a function effect(Character a, Character b) and also take the Board singleton into account. I do this to be able to code every effect imaginable, that's easy when prototyping and allow for deep gameplay.
To do this, I created a singleton scene AttacksList. Every child of AttacksList extends from Attack, and implements effect(a, b)

Characters can have a list of Attacks, they have a @export var attacks:Array

Q1: Am I doing things right, is my architecture correct ?
Q2: I would also like to do it the enum way, like this:

AttackList, enum ATTACK_NAME {ATTACK1, ATTACK2, ATTACK3}, func getAttack(name:ATTACK_NAME ) -> Attack

  • Attack 1, attackName = ATTACK_NAME .ATTACK1
  • Attack 2, attackName = ATTACK_NAME .ATTACK2
  • Attack 3, attackName = ATTACK_NAME .ATTACK3
  • ...

but can't find a way to edit enum values in arrays in the editor, there is no enum type.
Should I just create an array of Strings in Character and transform them to enum values with ATTACK_NAME .get("STRING_ATTACK"), but will lost the autocomplete feature ?

Q3: If Q2 is impossible, it seems also impossible to get a node_path of a singleton from the editor, is it true ? In this case, should I just put the AttackList in the main scene ? (this is not optimal since other scenes like the perk selector will need to access the AttackList too)
Q2-3: Is C# generally more suitable in cases where the gameplay logic rely heavily on OOP ?

Thank you in advance ^^,
sorry if my explanation was messy, I am not a godot master

  • Ok regarding typed arrays of enum in godot 4:

    enum LOL {MDR, PTDR, JPP}
    @export var lol:Array[LOL]

    Then in the editor you have:

    NOW this is power , godot understand that enum is int, but propose a dropdown !
    (I was using godot 4 alpha 2, now I've tried alpha 15. This is waaayy better)

This isn't a complete answer, but in Godot 3.x an enum's type is int.

In Godot 4.0, enum will be a real type. That's what I've read. I haven't used 4.0-alpha.

    DaveTheCoder

    I use godot 4 (because of the new tilemap options), and can't put enum values in an array into the editor, and it is also int, but when I @export var thing:ENUM it is a dropdown choice

    I kinda solved my problem by using regular OOP.
    AttacksManager have a dictionnary of attack, named... attacks (HashMap<String, Attack>in Java or C# or C++)

    I also have a function register_attack(attack:Attack) into AttacksManager. Each children of Attack(Heal, Poison, Stab, AnyAttackYouCouldThink) will do super._ready()into _ready

    With this, AttacksManager will allow O(1) access to Attack, but will require exact attack name in Character list of attacks, since those are String, because godot does not seems to support it in arrays (it works well in non arrays).