Upgrading a building

In the past week I added building upgrades to the lineup. A player can now activate(e press) on a block on the building with new Building Upgrade Tool which would trigger a screen with the information about the building (like its current level) and the “mighty” Upgrade Building button. After the player presses this button an Upgrade task is added to the Holding and can be claimed by an Oreon.

Activated block is part of a building?

The underlying challenge in implementing the above flow was to detect whether the acitvated block was part of one of the many buildings in the village and if yes which one. AABB collision detection[1] to the rescue. The Structure Template prefab which I used to place buildings in the world consists of the regions(relative to the centeral block) encompassed by the building. Using these regions and the center block position I was able to construct the target ‘rectangle’ for each building and iterate through them when the player uses the upgrade tool to activate a block(forms the 2D region to be investigated) to check if this block is part of any of the regions owned by a building.


This week I also added a Resources class which can be used to add various types of resources. A type of resource extending the abstract Resource class will have the hungerSatisfaction and a healing attribute which could be used later to define the effects of these resources when used. The player would use these resources to carry out various tasks in the village like spawning Oreons, using them for Research and supplying them to buildings in the village which are dependent on these resources to function.

Required by buildings to function

Various buildings in the village can now have resource related constraints to function. Currently the Diner requires a Cookie Crop to serve each Oreon. So, whenever the Oreon is assigned an eat task after reaching a Diner it is checked whether the Oreon can be served, if not the Oreon is freed and it tries again after some time.

The Storage

The conveniently named Storage building can be used by the player to store resources they collected from the village. The player can walk into the Storage and drop blocks to add them to the building’s chest from where they can be retrieved later. This building thus helps avoid cluttering the player inventory with blocks that they do not require at the moment but have gathered for use in the future.


Compiling known issues

I also compiled some known issues in the current implementation of the MOO in its repo, so that they do not get lost and can be tracked easily through the project board. Here is a list of all these issues and also the PR which consists of the features implemented this week,

A shocking revelation

With above PR merged all the tasks in the Month 2 of the timeline according to my proposal are finished. So you can say I am a bit ahead of schedule :D . This means that now I have got some time to knock down a few issues from the “big” list above in the upcoming weeks of this month, yay!

+ What is AABB collision detection?
AABB stands for Axis Aligned Bounding Box which is a fairly memory efficient way to represent a 3D volume. We store the information about a volume by storing the coordinates of its vertices, or the coordinates of the center and the length of various sides of the vertices etc. which has a much less toll the memory than say if we stored the coordinates of each point inside the volume. This technique is very useful in detecting if two volumes are touching or in other words collided. The extents of the each volume define the `x`, `y` and `z` ranges of each of these volumes, so if these overlap we can say that the two blocks have collided. In conclusion, AABB is just a fancy way of representing volumes while also considering the memory and computational sides of the picture. This question on StackOverflow also has some great answers explaining AABB.