Extending Subsystems
Extending Subsystems to Customize Integration
All of the subsystems hanging off GameInstance
and LocalPlayer
can be extended to add custom behavior. Additionally, the PlayerInfo
class can be extended, as well as the subobjects that hang off it, such as PlayerInventory
.
For example, if we wanted to add custom behavior to the CatalogSubsystem
and PlayerInventory
, we’d create three classes:
UCLASS()
class UMyPlayerInventory : public URH_PlayerInventory
{
GENERATED_BODY()
public:
UMyPlayerInventory(const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer)
{
}
};
UCLASS()
class UMyPlayerInfo : public URH_PlayerInfo
{
GENERATED_BODY()
public:
UMyPlayerInfo(const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer.SetDefaultSubobjectClass<UMyPlayerInventory>(TEXT("PlayerInventory")))
{
}
};
UCLASS()
class UMyCatalogSubsystem : public URH_CatalogSubsystem
{
GENERATED_BODY()
public:
UMyCatalogSubsystem(const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer)
{
}
};
Once those are compiled, launch the Unreal Editor and navigate to Edit → Project Settings...
.
Under the Plugins
section in the left pane of the window, select Rally Here Integration Settings
, then scroll down in the right pane to the Subsystem Classes
section.
Set the Catalog Subsystem Class
to MyCatalogSubsystem
and Player Info Class
to MyPlayerInfo
.
Note that the MyPlayerInventory
class is being pulled in via the Player Info Class
override using Unreal’s ObjectInitializer
system: Super(ObjectInitializer.SetDefaultSubobjectClass<UMyPlayerInventory>(TEXT("PlayerInventory")))