In this chapter, we are going to build a customizable weapon system. Throughout the game, the player will be able to upgrade its bike's primary weapon by purchasing attachments that will augment specific properties, such as range and strength. The primary weapon is mounted on the front of the bike and has two expansion slots for attachments that the player can use to build various combinations. To build this system, we are going to use the Decorator pattern. It should not be a surprise because its name implies its use, as we will see further in the chapter.
The following topics will be covered in this chapter:
- The basic principles behind the Decorator pattern
- The implementation of a weapon system with attachments