Health: The Journey
The Objectives
My GSoC was aimed at Health in Terasology. My primary goal was to extract Health logic from the Core module to its own separate module. Why was this needed? This would “slim” the engine and increase extensibility of Health system. The restoration logic creation helped in efficient healing, as we moved from the every-tick regen to scheduler based regeneration, removing the need of the heavy getEntitiesWith()
call. The refactoring of the logic and creating separate systems for damage and health leads to better overall performance, as health is fundamental, and increases reliability of logic.
The continuation of this was to separate the logic flow inside the Health itself. This led to changes in the APIs for healing, which required changes in lots of modules.
I was also able to complete a stretch goal of documenting ways of how to implement point-based systems. Lets get into the details of the things that were done.
The past, the present & the future
The past implementation of Health, in the core module, used a single logic flow for all healing of entities:
In the journey of my GSoC project, I tried to separate the two fundamental healing in the game: regeneration, the natural healing of player, and restoration, the magical healing of an entity. Although the restoration is nearly the same as the legacy health logic, the restoration is fairly new.
This Pull Request, which has reference to all module changes, signifies the moving forward to the separate independant logic flows from the single logic flow:
The present of the Health is the Health System, which explains the new implementations and how to use them. The 96 commits, 23 PRs and 7 issues pretty much sum up the first two-third of the coding period of GSoC.
One of my goal, which got re-worked into stretch goal with a design piece, was to create a uniform implementation for all “points” based systems, which have same functionalities and possibly the same APIs, such as health, hunger and thirst. I started out with building stuff around that area, but went on to focus more on Health.
Hence, in the later part of the project, I worked on writing some of the ways of implementing such systems: unique component based, register system and code generation, which can be used based on the specific use case. All of that can be found in the Point pool wiki
The project that I proposed was complete, Hurray! But there is always scope of improvement both in terms of code quality and performance. The way ahead for the Health, in my view, would be a combined implementation for all “point” meters with good “moddability” and “uniformity” in them.
Testing and Documentation all the way
Right from the beginning, I was having a clear goal of properly testing my code at every stage possible. Testing module of Terasology, ModuleTestingEnvironment came in very handy in this.
With its help, I was able to write unit tests for almost all of the functionalities of legacy health before extraction, and most of the functionalities of new implementation. Even though it was a not a test-driven development, it was at least well tested development from my side.
As my project was primarily based on Java, I tried to add documentation for the code as JavaDoc in the source itself.
The Main stuff
The 96 commits, 23 PRs and 7 issues pretty much sum up the first two-third of the coding period of GSoC.
The major work that I did was in the Health Module. The Pull Requests in chronological order:
- Health#1 - Health#2 - Health#3 - Health#4 - Health#5
- Health#6 - Health#7 - Health#8 - Health#10 - Health#13
- Health#15 - Health#16 - Health#17 - Health#18 - Health#22
- Health#23 - Health#24 - Health#25 - Health#27 - Health#29
Refactor stuff
The PRs that I created (and got mergerd!) during the coding period are following apart from the Engine PR and PRs in Health module itself:
- Potions#53 - Alteration#12 - AdventureAssets#23 - HealingBlocks#1
- GooKeeper#15 - FunnyBlocks#14 - Equipment#120 - DamagingBlocks#10
- CombatSystem#38 - Breathing#6 - WoodAndStone#50 - Anatomy#7
- Behaviors#17 - Inferno#5 - TutorialBehaviors#4 - SnakeTournament#7
- Hunger#15 - Miniion#8 - WorkstationCrafting#8 - LightAndShadow#98