News Liste Going Medieval

Medieval Monday Talk #50 — Rewriting Buildings
Going Medieval
12.08.24 13:19 Community Announcements
Greetings, medievalists!

In today's MMT we're talking about BUILDINGS! Well… more like… refactoring of buildings. We’ve done refactoring of other stuff before, but building refactoring is a bit harder to describe. This is going to get very technical, but for the sake of transparency and to understand how big of a change this is, we’ll try to explain it as best as we can - in layman’s terms.

Previously, we used a method called inheritance to create and manage buildings in our code. Inheritance is the mechanism of basing an object or class upon another object, retaining similar implementation. We had a base class called BaseBuildableObject that contained common code for things like construction, deconstruction, and storage. Think of a base class as a master blueprint. It's a basic plan that other, more specific blueprints are based on. All constructions were derived from this base class, and that’s why we created two separate instances:
  • BuildingInstance: Inherited from BaseBuildableObject.
  • FurnitureInstance: Also inherited from BaseBuildableObject.


One would be for building and the other one for furniture. If we had to introduce a new object within furniture, and that object would have some furniture properties but not all of them - we would have to expand FurnitureInstance and create a new class that inherited it. That could work, but it’s far from good practice, as we would have to expand FurnitureInstance each time we would add a new thing. We would just add unnecessary code that could be accessed from all classes that inherit it.


In this old architecture system, we had separate .json files for each building type. Basic buildings were in one .json file (such as walls, doors, stairs… in the Buildings.json), furniture was in another file (tables, chairs, beds… in the Furniture.json) and so on (check all these .jsons in the steamapps\common\Going Medieval\Going Medieval_Data\StreamingAssets\Constructables).

So, for the game to access that new furniture, it would have to go through the Furniture instance, process all of the code that covers functionality of every furniture, in addition to accessing the separate code of that new furniture. That can cause unnecessary processing power and extra steps for the whole process.

To solve those issues we’ve decided that it’s best to rewrite (technical term REFACTOR) all code related to buildings. The new approach we’re using is called component based architecture.

Component based software architecture is a style of writing code in multiple different classes (called components) that do one specific thing. Components are loosely-coupled and can be reused, making the code base easier to modify and expand without adding unnecessary code.

Now, we will have one single storage file with all the possible buildings inside it, called BaseBuildingRepository. However, they initially don't do anything except take up space in the game world. For example, beds can't be slept on, production buildings don't produce anything, and torches are always off and don’t give out heat. With just this .json, you would only be allowed to construct buildings and they would need resources for construction. Here is an example of campfire code in the old architecture (left) vs the new one (right).



To give buildings their functionalities, we had to create specific components for each building type: BedComponent for beds, TableComponent for tables, ChairComponent for chairs (TrapComponent, GraveComponent, DoorComponent, ProductionComponent) etc. Each component type will have its own JSON file describing its functionality.

To tie it all together, we have to do a couple of things. The first is done in Unity via prefab editing. In game development, a prefab is a ready-to-use model of an object (like a campfire), which you can then add specific functionalities to, like making it actually produce heat or light. In our case, a camp_fire prefab will require, among other files, a ProductionComponent.



The second thing is that we need to specify the productionComponentID within the campfire id in the BaseBuildingRepository.json.



This references a specific production component that the campfire will use. It could be any production component, not just for campfires. It doesn’t need to be a campfire component - it can be a research table component or a skep component (basically any production component). To make it more clear, here’s a snippet from the new ProductionComponentsRepository.json for campfire:



Notice how it only contains information about productions, no information about buildings.

Same principle goes for all other buildings. Some .json files may be nearly empty, like this one for caravan post (CaravanPostComponentRepository.json):



That’s perfectly normal. If we wish to expand caravan post functionality later on, we can edit that .json file and add appropriate code to the caravan post component. That way, all code related to a single type building will be contained in just a few classes and it’s much easier to debug everything (if there are issues with buildings of a certain type, we know exactly where to look as each building will have its own component now). And this will make modding of the game that much easier.

So, that’s why this is a big deal to us and why it took a lot to do it. We had to cover all of the building types and tie them all together in this streamlined coding web and this will make development much smoother as we go forward. And don’t worry, this will not break your existing saves.

Did you understand this? Does it make sense, even if you are not familiar with coding? We’re asking in order to figure out if these tech talks are worth going into such detail next time if/when they happen.

In any case, there are more things to talk about - like what you can expect from prisoners and their behavior. We've listened to your feedback and we'd like to extrapolate their functionality and that's worth at least one more MMT. Sooo... talk to you again in two weeks. Until then,

Stay medieval!

Foxy Voxel

Discord Reddit X/Twitter TikTok Facebook
Logo for Going Medieval
Release:01.06.2021 Genre: Simulation Entwickler: Foxy Voxel Vertrieb: The Irregular Corporation Engine:keine Infos Kopierschutz:keine Infos Franchise:keine Infos
Einzelspieler Mehrspieler Koop

Aktuelle Steam News
Neue Steam News in der ePrison Datenbank

Patch Notes (0.20.25)
Going Medieval
1 Tag 16:41 Community Announcements
Experimental Modding Introduction (0.21.11)
Going Medieval
11.11.24 14:17 Community Announcements
Patch Notes (0.20.24)
Going Medieval
07.11.24 15:02 Community Announcements
Patch Notes (0.20.23)
Going Medieval
05.11.24 11:43 Community Announcements
Patch Notes (0.20.21)
Going Medieval
30.10.24 15:28 Community Announcements
Patch Notes (0.20.20)
Going Medieval
29.10.24 15:52 Community Announcements
Experimental Branch Patch (0.20.19)
Going Medieval
29.10.24 12:51 Community Announcements
Roadmap Update
Going Medieval
29.10.24 12:16 Community Announcements
Patch Notes (0.20.16)
Going Medieval
25.10.24 15:02 Community Announcements
Patch Notes (0.20.14)
Going Medieval
22.10.24 13:26 Community Announcements
Patch Notes (0.20.13)
Going Medieval
17.10.24 13:52 Community Announcements
Patch Notes (0.20.12)
Going Medieval
16.10.24 11:21 Community Announcements
Update #12 | Prisoners & Gates
Going Medieval
15.10.24 10:02 Community Announcements
Experimental Branch Patch (0.20.9)
Going Medieval
14.10.24 15:50 Community Announcements
Experimental Branch Patch (0.20.8)
Going Medieval
11.10.24 14:25 Community Announcements
Experimental Branch Patch (0.20.7)
Going Medieval
10.10.24 16:44 Community Announcements
Experimental Branch Patch (0.20.6)
Going Medieval
09.10.24 15:36 Community Announcements
Experimental Branch Patch (0.20.5)
Going Medieval
08.10.24 17:18 Community Announcements
Experimental Branch Patch (0.20.4)
Going Medieval
07.10.24 16:11 Community Announcements
Experimental Branch Patch (0.20.3)
Going Medieval
04.10.24 15:52 Community Announcements
Experimental Branch Patch (0.20.2)
Going Medieval
03.10.24 18:31 Community Announcements
Experimental Branch Update (0.20.1)
Going Medieval
02.10.24 15:04 Community Announcements
Patch Notes (0.19.40)
Going Medieval
18.09.24 12:16 Community Announcements
Experimental Branch Patch (0.19.40)
Going Medieval
17.09.24 14:19 Community Announcements
Patch Notes (0.19.39)
Going Medieval
11.09.24 11:13 Community Announcements
Experimental Branch Patch (0.19.39)
Going Medieval
10.09.24 11:04 Community Announcements
Medieval Monday Talk #52 — Impactful Entrance
Going Medieval
09.09.24 17:24 Community Announcements
Experimental Branch Patch (0.19.38)
Going Medieval
09.09.24 08:02 Community Announcements
Experimental Branch Patch (0.19.36)
Going Medieval
05.09.24 11:11 Community Announcements
Experimental Branch Patch (0.19.34)
Going Medieval
30.08.24 12:54 Community Announcements
Experimental Branch Patch (0.19.33)
Going Medieval
29.08.24 09:03 Community Announcements
Medieval Monday Talk #51 — Prisoners Revision
Going Medieval
26.08.24 11:52 Community Announcements
Experimental Branch Patch (0.19.32)
Going Medieval
19.08.24 12:54 Community Announcements
Medieval Monday Talk #50 — Rewriting Buildings
Going Medieval
12.08.24 13:19 Community Announcements
Patch Notes (0.19.30)
Going Medieval
12.08.24 07:37 Community Announcements
Experimental Branch Patch (0.19.30)
Going Medieval
08.08.24 07:56 Community Announcements
Experimental Branch Patch (0.19.29)
Going Medieval
29.07.24 13:29 Community Announcements
Patch Notes (0.19.28)
Going Medieval
29.07.24 10:30 Community Announcements
Medieval Monday Talk #49
Going Medieval
29.07.24 08:20 Community Announcements
Medieval Monday Talk #48
Going Medieval
15.07.24 15:33 Community Announcements
Experimental Branch Patch (0.19.28)
Going Medieval
09.07.24 11:03 Community Announcements
Patch Notes (0.19.27)
Going Medieval
28.06.24 12:43 Community Announcements
Patch Notes (0.19.25)
Going Medieval
27.06.24 13:52 Community Announcements
Patch Notes (0.19.24)
Going Medieval
26.06.24 11:33 Community Announcements
Patch Notes (0.19.23)
Going Medieval
25.06.24 08:57 Community Announcements
Patch Notes (0.19.22)
Going Medieval
21.06.24 14:10 Community Announcements
Patch Notes (0.19.21)
Going Medieval
20.06.24 07:58 Community Announcements
Medieval Monday Talk #47
Going Medieval
17.06.24 15:05 Community Announcements
Experimental Branch Patch (0.19.17)
Going Medieval
14.06.24 11:34 Community Announcements
Patch Notes (0.19.16)
Going Medieval
11.06.24 11:59 Community Announcements
Patch Notes (0.19.14)
Going Medieval
06.06.24 13:12 Community Announcements
Patch Notes (0.19.13)
Going Medieval
04.06.24 14:25 Community Announcements
Patch Notes (0.19.12)
Going Medieval
03.06.24 15:15 Community Announcements
Update #11 | Events & Roles
Going Medieval
30.05.24 09:08 Community Announcements
Experimental Branch Patch (0.19.10)
Going Medieval
29.05.24 12:49 Community Announcements
Experimental Branch Patch (0.19.9)
Going Medieval
27.05.24 14:47 Community Announcements
Experimental Branch Patch (0.19.8)
Going Medieval
24.05.24 16:39 Community Announcements
Experimental Branch Patch (0.19.7)
Going Medieval
23.05.24 16:06 Community Announcements
Experimental Branch Patch (0.19.5)
Going Medieval
21.05.24 15:24 Community Announcements
Experimental Branch Patch (0.19.4)
Going Medieval
20.05.24 15:08 Community Announcements
Experimental Branch Patch (0.19.3)
Going Medieval
19.05.24 07:15 Community Announcements
Experimental Branch Patch (0.19.2)
Going Medieval
17.05.24 13:31 Community Announcements
Experimental Branch Update (0.19.0)
Going Medieval
16.05.24 15:07 Community Announcements
Medieval Monday Talk #46
Going Medieval
13.05.24 13:05 Community Announcements
Patch Notes (0.18.19)
Going Medieval
08.05.24 11:43 Community Announcements
Medieval Monday Talk #45
Going Medieval
29.04.24 11:31 Community Announcements
Hotfix Notes (0.18.18)
Going Medieval
26.04.24 13:05 Community Announcements
Update #10.5 | Migration & Camera Changes
Going Medieval
22.04.24 11:26 Community Announcements
Medieval Monday Talk #44
Going Medieval
08.04.24 11:55 Community Announcements
Experimental Branch Patch (0.18.8)
Going Medieval
03.04.24 13:10 Community Announcements
Experimental Branch Patch (0.18.7)
Going Medieval
28.03.24 14:19 Community Announcements
Experimental Branch Patch (0.18.5)
Going Medieval
22.03.24 21:32 Community Announcements
Experimental Branch Patch (0.18.3)
Going Medieval
20.03.24 13:54 Community Announcements
Medieval Monday Talk #43
Going Medieval
18.03.24 15:07 Community Announcements
Patch Notes (0.16.26)
Going Medieval
13.03.24 14:28 Community Announcements
Experimental Branch - Save Migration Guide
Going Medieval
07.03.24 10:39 Community Announcements
Patch Notes (0.16.24)
Going Medieval
06.03.24 13:51 Community Announcements
Patch Notes (0.16.23)
Going Medieval
29.02.24 11:28 Community Announcements
New Save System is coming soon
Going Medieval
26.02.24 18:54 Community Announcements
Patch Notes (0.16.22)
Going Medieval
26.02.24 12:38 Community Announcements
Patch Notes (0.16.20)
Going Medieval
13.02.24 12:26 Community Announcements
Hotfix Notes (0.16.19)
Going Medieval
07.02.24 12:27 Community Announcements
Hotfix Notes (0.16.17)
Going Medieval
06.02.24 11:48 Community Announcements
Hotfix Notes (0.16.16)
Going Medieval
05.02.24 12:03 Community Announcements
Patch Notes (0.16.15)
Going Medieval
01.02.24 13:52 Community Announcements
Patch Notes (0.16.14)
Going Medieval
25.01.24 13:03 Community Announcements
Patch Notes (0.16.13)
Going Medieval
18.01.24 14:49 Community Announcements
Happy Holidays!
Going Medieval
22.12.23 14:27 Community Announcements
Patch Notes (0.16.10)
Going Medieval
20.12.23 14:05 Community Announcements
Hotfix (0.16.9)
Going Medieval
08.12.23 14:11 Community Announcements
Patch Notes (0.16.8)
Going Medieval
07.12.23 08:05 Community Announcements
Hotfix (0.16.7)
Going Medieval
23.11.23 14:05 Community Announcements
Nominate Going Medieval for Labor of Love 2023 Steam Award
Going Medieval
22.11.23 12:56 Community Announcements
Update #10 | Water & Fishing
Going Medieval
21.11.23 10:56 Community Announcements
Experimental Branch Patch (0.16.6)
Going Medieval
20.11.23 10:51 Community Announcements
Experimental Branch Patch (0.16.5)
Going Medieval
17.11.23 10:37 Community Announcements
Experimental Branch Patch (0.16.4)
Going Medieval
15.11.23 11:28 Community Announcements
Experimental Branch Update (0.16.2)
Going Medieval
10.11.23 14:06 Community Announcements
Medieval Monday Talk #42
Going Medieval
30.10.23 13:39 Community Announcements
Medieval Monday Talk #41
Going Medieval
16.10.23 12:25 Community Announcements
Medieval Monday Talk #40
Going Medieval
02.10.23 13:26 Community Announcements
Medieval Monday Talk #39
Going Medieval
18.09.23 12:15 Community Announcements
Medieval Monday #38
Going Medieval
04.09.23 14:34 Community Announcements
Hotfix (0.15.8)
Going Medieval
23.08.23 12:46 Community Announcements