Entity system refactor + frontend changes


Hello,

Today, I've completely refactored the entity system and abandoned the old trigger target paradigm, which is now replaced by proper event handling. Maps have been reworked and in overall contain less map entities since we only need 1 map entity with a script attached to manage the gameplay flow.

Let me introduce events to you:

You can add an event handler either from a host application or a script, which will influence how the gameplay flow shapes. Imagine you walk towards an NPC and want to initiate a dialogue with him. The old way was to make use of area map entity, which tracked which other entities are within its radius. The area entity would then ask entities within the radius if it can trigger itself. Once area entity would get triggered (player pressed use key), it would load a dialogue file in hardcoded fashion. Sadly, this means that adding further functionality to the area map entity is almost impossible without creating its derivatives. Henceforth, I've decided to trigger an event instead.

Area map entity would then trigger the specified event, while optionally providing the arguments.

But someone has to listen for such event, look no further because the map also contains a script map entity. Script map entities load a script from a disk, which can listen to various events and execute arbitrary commands:


This is an example of a script which pairs with the bouncing_ball dialogue example:

As you can see, it's just a matter of listening to a specific event. We invoke a natively registered method within the game to initialize a dialogue then.

Things to be aware of:

It's strongly encouraged to develop features on the host (Go) side, because scripts inflict a performance penalty. It is not recommended to use scripts for heavy tasks or calculations. Make sure you always off-load such tasks to a native method and simply fetch the results from invoked method afterwards.

With that being said, the demo's title screen was actually a hack before. I made a map called 'start' that relied upon derived talk map entity (now removed entity type, since we handle dialogues directly now) which then loaded a dialogue file called `intro.json`. This was however bad, because we don't want the main menu to be presented as a map with entities. Therefore, I've decided to re-write the main menu as an actual play state, being part of the game itself. No longer we load a start map to see all other maps to test.

Thanks for reading this!

Files

Tech demo for Linux Universal 7 MB
Version 5 Jan 10, 2019
Tech demo for Windows 64-bit 8 MB
Version 5 Jan 10, 2019

Get Rurik Framework

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.