This post is aimed at the 0AD Devs and more specifically, people that are aware of how the component and AI files function.
Lately, I have been working on a large AI project for HC and recently made an attempt to register a new event inside the components that I can use inside the AI files.
However, I am pretty sure I am still missing something after going through multiple files and testing my attempts.
For example, I tried to replicate the method that was used for the TrainingFinished event.
The actual registering of this particular event seems to be taking place in the productionqueue: https://gyazo.com/0da3f8f4de7211345e41c9f95c3a57eb
Afterward, it seems the communication between the component and the AI takes place inside the AIProxy and AI Interface components: https://gyazo.com/97879f508c2280e2b5dbb3c0888f15f8 https://gyazo.com/0210965d087367d766b53e3c2cb7fc65
I am aware of the Trigger component file, but this doesnt seem to have a specific connection to the AI files in my testing.
Whenever I try to copy this method of registering a new event and read it from the AI files it gives me the following error: https://gyazo.com/b85b0c086a517b3408682a44f09fc7f9
This leads me to the gui files where the startgame function is called, which (I assume) goes through the source code where these events might be checked.
Also, I tried to replicate this using the ResearchFinished event, which is only registered inside the Trigger component.
When I try to communicate this event using the AI components, it does not give me this error, but also doesnt actually run the OnResearchFinished function, which seems to be called somewhere from the source as well, since I cant find where this is called within any of the component files or other files that I went through for that matter.
I believe that the code that calls these functions is looking for a function that starts with "On blah blah", since other functions that dont start with these 2 characters are ignored, but this is just a sidenote.
Finally, I have come to the conclusion that I am probably missing some kind of event handler register that must be done for any event whether it be used for the Trigger or AI Interface component.
I have no clue where this is located and also leads to my actual question.
I would like to know what I am doing wrong here and/or even better, a description on how to register new events and communicate these properly between scripts.
If anyone is able to explain this to me, I would greatly appreciate this.
Anyway, thanks for reading this long post for the people who have and I hope someone can give me some insight into this problem.