0 votes

I'm trying to implement a modular command system for my game (tactical RPG) and the ideia behind the method was to create Resources (Commands) that would have a besides the name and other stuff, a reference to a method!! Reference to methods cannot be exported so I came up with this solution.

[url=https://ibb.co/fbOrsf][img]https://preview.ibb.co/g9yPCf/Captura-de-ecra-2018-11-02-a-s-23-36-05.png[/img][/url]

this would make it so the resource now has a drop down enum containing all the methods existing inside the ActionsCode.gd file. This file would have this structure:

[url=https://ibb.co/gbULk0][img]https://image.ibb.co/i36cXf/Captura-de-ecra-2018-11-02-a-s-23-36-35.png[/img][/url]

this would allow me to store all the command methods inside a file and then reference them the commands would receive as arguments whatever I intended. And I could call them as:

ActionsCode.new().call(method_name)

Another alternative I though of would be storing all the commands inside a folder... use the directory class to go through them, create the enum just like in the first image.. but now each Command would be stored inside a different file and could be called using:

load(my_command_path).new().execute(arguments);

"execute" would be a common entry point for each command.
What do you think, what would be the cons and pros of these approaches... the ideia is to separate code from design when working in projects with programming team and design team.

in Engine by (28 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.