Back to code to finish up

Having everything set in the editor and level, we have a few more code changes to make. First, we make some changes in MasteringInventory.h:

USTRUCT()
struct FWeaponProperties
{
        GENERATED_USTRUCT_BODY()
 
public:
 
        UPROPERTY()
        TSubclassOf<class AMasteringWeapon> WeaponClass;
 
        UPROPERTY()
        int WeaponPower;
 
        UPROPERTY()
        int Ammo;
};

We add this struct to the very top of the file, just after the #include header section. We will use this in the inventory list to reference weapons from now on, instead of referencing the MasteringWeapon class itself directly (but, of course, this is now a member in the struct for our use). We use the struct to track two new properties we associate with weapons: ammo and weapon power.

Next, after ...

Get Mastering Game Development with Unreal Engine 4 - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.