TraitDataBuilder - rspforhp/WildfrostModdingDocumentation GitHub Wiki

TraitDataBuilder

TraitDataBuilder(WildfrostMod mod)

  • The builder for creating TraitData.
  • Traits are a way to associate keywords with effect(s).
  • Making a trait also allows you to add the trait to a card via console command (add trait).
  • Standard naming convention is all lowercase and no spaces.
  • All vanilla traits can be found in the references.

Example

Below is how the barrage trait could be coded using TraitDataBuilder.

Remember that the Get method can only fetch data that is already loaded. Using custom keywords and effects may require using the SubscribeToAfterAllBuildEvent method. Whether this is necessary depends on the structure of your code (TraitData is one of the last to be loaded). Assuming the keyword and effect was not in the base game, the code may look like this instead.

//'this' refers to an instance of a WildfrostMod class

TraitDataBuilder barrage = new TraitDataBuilder(this)
    .Create("Barrage")
    .WithOverrides(Get<TraitData>("Aimless"), Get<TraitData>("Longshot"))
    .SubscribeToAfterAllBuildEvent(
        (trait) =>
        {
            trait.keyword = Get<KeywordData>("barrage");
            trait.effects = new StatusEffectData[]{ Get<StatusEffectData>("Hit All Enemies In Row") };
        });

//Note: making the builder is not the same as loading the TraitData into the game. There is an additional step.
//See Tutorial 2.

Methods

WithKeyword

WithKeyword(KeywordData data)

See also: KeywordDataBuilder, WithIsReaction

  • Used to assign a keyword to the trait.
  • data is the keyword that is assigned.
  • When a card with this trait is hovered over, and this keyword uses .WithShow(true), the keyword's description text will pop-up.
  • When a card's reaction icon is hovered over, and this trait uses .WithIsReaction(true), the keyword's description will appear in the reaction's text popup, eg "This card will ".

WithEffects

WithEffects(params StatusEffectData[] effects)

  • Used to assign effects to the trait.
  • effects is a list of effect(s), separated by commas, i.e. WithEffects(effect1, effect2).
  • To get an StatusEffectData from the effect's name, use Get<StatusEffectData>(string name).
  • If the effects have a description, these descriptions will show up on the cards (that is, don't give these effects descriptions)

WithOverrides

WithOverrides(params TraitData[] traits)

  • Used to list other traits that would conflict with this trait, i.e. barrage and aimless.
  • traits is a list of trait(s), separated by commas, i.e. WithOverrides(trait1, trait2).
  • To get an TraitData from the trait's name, use Get<TraitData>(string name).
  • Charm that give traits cannot be put on cards with any of the trait's overrides.

WithIsReaction

WithIsReaction(bool isReaction)

See also: StatusEffectDataBuilder.WithIsReaction

  • Only adds the keyword's description text to a card's reaction popup, if its reaction icon exists.
  • If the reaction icon doesn't exist (eg the card has no effect with .WithIsReaction(true)), then nothing happens.
  • This will not add a reaction icon to the card. Only the effects can do this.
⚠️ **GitHub.com Fallback** ⚠️