Expanding Array of a Parent Class

Hi, only need to get my head straight on this. Scripting on another engine so I am a little lost.

I have a Script - call it my SuperGameElement.uc it contains a function array and corresponding static functions.
Example:

static function array<MyTemplate> CreateTemplates()
{
local array<MyTemplate> MyAwesomeList;
MyAwesomeList.AddItem(CreateAwesomeTemplate01());
MyAwesomeList.AddItem(CreateAwesomeTemplate02());

   ...

}

static function MyTemplate CreateAwesomeTemplate01()
{
filled with awesome-ness
}

Alright, good enough. I don´t want to alter my “SuperGameElement.uc” it might get altered in the future however.

So, how do I subclass to update the function array ?

MyGameElementAdditions.uc

                MyGameElementAdditions extends SuperGameElement

static function array<MyTemplate> CreateTemplates()
{
local array<MyTemplate> MyAwesomeList;
MyAwesomeList.AddItem(CreateAwesomeTemplate9999());

}

static function MyTemplate CreateAwesomeTemplate9999()
{
filled with more awesome-ness
}

Somehow, I miss something …

Thanks in advance :slight_smile:

Welcome to the forums.

So you want the array returned by MyGameElementAdditions::CreateTemplates to contain the items as in SuperGameElement::CreateTemplates plus any new items you may want?

In that case you can do this in MyGameElementAdditions::CreateTemplates


static function array<MyTemplate> CreateTemplates()
{
	local array<MyTemplate> MyAwesomeList;

	//get list with items filled by superclass version
	MyAwesomeList = class'SuperGameElement'.static.CreateTemplates();
	//add any other items here
	MyAwesomeList.AddItem(CreateAwesomeTemplate9999());

}