Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Skeleton" entries for Unavailable Commands #6

Open
ckx opened this issue Dec 26, 2015 · 0 comments
Open

"Skeleton" entries for Unavailable Commands #6

ckx opened this issue Dec 26, 2015 · 0 comments

Comments

@ckx
Copy link
Owner

ckx commented Dec 26, 2015

Some commands aren't usable when a game is initially launched, because they rely on members of classes which aren't instantiated yet (especially for debug stuff). I dislike that these commands are not added to the commands output, so in one game project, I wrote a helper function to add unavailable commands to the console.

            InitialConsoleCommands.Add("Scene", new List<string[]>() { new string[2] { "list_scene_entities", "Lists all entities currently in a scene." } } );
            InitialConsoleCommands.Add("DrawSystem", new List<string[]>() { new string[2] { "draw_hitboxes", "Draws all hit / hurt boxes on screen." },
                new string[2] { "draw_wireframe", "Enables wireframe mode."} });

            foreach (KeyValuePair<string, List<string[]>> kvp in InitialConsoleCommands) {
                foreach (string[] sa in kvp.Value) {
                    devConsole.AddCommand(sa[0], delegate {
                        devConsole.Log($"Unavailable command. {kvp.Key} object is required before usage.");
                    }, sa[1]);
                }
            }

This is a problem that might be better solved in the game console library. A simple "AddUnavailableCommand" would do.

  • Unavailable commands should be indicated as "Not yet usable" or something in the output of commands
  • When a new command is added to the main commands map, it should iterate over all the unavailable commands, and remove the appropriate "unavailable" element.

While doing this, consider loading commands from a data file to make the whole skeleton command process simple across different projects (and to keep command documentation out of code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant