After completely moving the health related systems to the new Health module, I tried to refactor some and implement Regen logic. Let’s see what things did I do in the week …

Making things work

First thing I did this week was to make sure that the newly created module to work, not only independantly, but also be able to handle “health”. What better module than to refactor the Potions module?

After adding Health as dependancy of Core, only minimal changes were needed to make sure that the effects in Potions module work. The work can be seen in the following PRs:

After making this changes, I tested out all the Potions available (and working, and related to Health) to make sure that nothing has broken because of the extraction. The next part was to go ahead with my plan of adding new logic flows…

Adding new Events

I added some two new events, namely BeforeRegen and OnRegened. The logic flow I thought was: BeforeRegen -> Entity regenerates -> OnRegened. I removed trigger event from the flow because I thought that it was unnecessary as the regen is all done by Health system itself. The PR with these changes are:

But I got review that since this way of doing Regen is arcahic, we should probably think about alternate way to do this. Also, it was suggested (by Cervator) that as the HealthAuthoritySystem is already doing so much, we should move out the newer logic to separate system.

So, I created a new system, the RegenAuthoritySystem to handle the regeneration logic, moving over the regen (with the new events) to the new system. The PR for the work done is:

What next?

After some extensive discussion on how to go on with the Regen logic, it was concluded that we should shift from the UpdateSubscirberSystem for applying regeneration to using some scheduler, which may have to be written just for Regen. After moving to scheduler, the way to cancel regen should be made more efficient, as the proposed logic sends too many events.

Hopefully, I would be able to complete Regeneration before the first Work Review next week…