Builders - rspforhp/WildfrostModdingDocumentation GitHub Wiki
Builders allow u to easily create and manipulate game data files, like cards and effects. The main API provides you a handful of those.
First i suggest making something like this in your mod file, to simplify the process of extending your code later.

Then later just extend them with other data types.
Now if u followed the previous tutorial declare this.

Thats basically all u need to be ready to create cards.

This makes a simple card that does nothing much yet, but we can modify it using everything with CreateUnit and CreateItem. See CardDataBuilder for more information.
In total, there are 18 data types (all derived classes of DataFile) can use builders:
- BattleData
- BossRewardData
- CampaignNodeType
- CardData
- CardType
- CardUpgradeData
- ChallengeListener
- ChallengeData
- ClassData
- EyeData
- GameMode
- GameModifierData
- KeywordData
- StatusEffectData
- BuildingPlotType
- BuildingType
- TraitData
- UnlockData
All of these data types have an associated builder. These builders provide a nice base of methods for editing data files. Builders can also be extended if you desire to build your own helper methods. Using builders is highly recommended. Although creating these data files can be done in alternate ways, it is a worse experience. Getting help when things go awry is slim when you try to reinvent the wheel.
For more info on the undocumented builders take a look at the insides of the builder using inspection tool of your IDE.
Create(string name) or Create<X>(string name)
- Creates an empty instance of the desired data type, which copies will be built from.
- For
Create<X>, X must be a derived class of the expectedDataFileclass (i.e.CardDataforCardDataBuilder,StatusEffectDataforStatusEffectDataBuilder, etc.). - Specific builders may opt to build on top of it (i.e.
CardUpgradeBuildercan useCreateCharminstead ofCreatedirectly).
FreeModify(Action<T> action) or FreeModify<D>(Action<D> action)
- Allows you to perform an action on the data instance directly rather than through the builder.
- Useful for fine-tuning parameters or editing parameters not possible through the builder's other methods.
- This is very useful for
StatusEffectDataas it allows you to edit parameters of classes that extendStatusEffectData, such asStatusEffectApplyX.
SubscribeToBuildEvent(AfterBuildDelegate d)
- Assigns a delegate that is executed when the instance is built.
- The built object is given to d as a parameter.
- There is an unsubscribe variant to this method.
SubscribeToAfterAllBuildEvent(AfterBuildDelegate d)
- Assigns a delegate that is executed after all builders have built and loaded their respective data into the game (so
Getcan now find them). - Used to allow flexibility in referencing other created objects
- The built object is given to d as a parameter.
- There is an unsubscribe variant to this method.
Edit<T, Y>(this T data)
- This is not a
DataFileBuildermethod; this is aDataFilemethod. - Used to create a
DataFileBuilderY with theDataFileT as its data. - When used in conjunction with
Clone()orInstantiateKeepName(), this method allows you to make a modified version of an existing card, status effect, etc.