Jack Reggin

Gameplay Programmer

Jack Reggin

Gameplay Programmer

Hex Engine
Banner
Genre Custom Engine, Turn Based Strategy Games
Engine N/A
Role(s) Gameplay Programmer, Tools Programmer, Scrum Master
Language(s) C++, Lua (Scripting), Javascript
Team Size 7
Duration 7 months
Genre Custom Engine, Turn Based Strategy Games
Engine N/A
Role(s) Gameplay Programmer, Tools Programmer, Scrum Master
Language(s) C++, Lua (Scripting), Javascript
Team Size 7
Duration 7 months
Hex Engine is a custom engine made specifically to make turn based strategy games that make use of a hexagonal grid. The engine exposes parts of itself to Lua so that games can be easily scripted by anyone. The editor was created completely from scratch with some tools created to help placing and manipulating tiles or units in the scene, editing parts of the scene itself, etc.
My tasks within this project included creating an event system that would act fairly similar to the way Unity's event system behaved. So functions like OnGameBegin within Lua are very easy to understand just by looking at them. I was also tasked with creating an external tool for auto-completion of code and showing help documentation. This took the form inside of Atom, a text editor, since it is very easily expandable using Javascript.

Event System

Lua Event Names
In the image above their are a few events that are called from the engine (C++) and are received by the Lua scripts. Most of them are easily noticeable, as mentioned before, due to their naming convention of having On prefixed to their name. However, there are some that are events that don't follow that convention, such as Init and Update. These events aren't just easy to use on the Lua side of things, but within the engine source code it is also very easy to invoke these methods when they should be invoked (see code below).
void Game::BeginGame(bool fromNetwork)
{
    ...

    // Send OnGameBegin event to the main script
    m_System.EventSystem->OnGameBegin();

    ...
}

Atom Lua Scripting

Auto Completion GIF
The above GIF is a view while using Atom with the plugin that I created installed. It will give the user some auto-completion help, as seen in the GIF above, and this also includes documentation regarding the class/function. The plugin that I created used the open source Github project called Atom Stingray as a basis and built upon it. Since Atom Stingray was built for another engine, I had to rip out the parts that were used for that engine exclusively and replace them with the parts used for the Hex Engine. Atom Stingray has a lot more features that aren't used by the Hex Engine, such as hot reloading of files, opening the editor, executing commands within the engine, etc. I used the auto-completion and help documentation parts of Atom Stingray.
The way that the auto-completion works is that the plugin will scan the file system at a certain location for a file called scriptbinds.json which contains all the information required to produce the auto-completion content. The file scriptbinds.json is generated by looking through XML files generated by Doxygen. This means that the source code within the engine can simply be commented using the Doxygen standard and this will be exported as documentation for Lua scripting in Atom. Very easy for the developers of the source code!