EyeDataBuilder - rspforhp/WildfrostModdingDocumentation GitHub Wiki

EyeDataBuilder

EyeDataBuilder(WildfrostMod mod)

  • The builder for creating EyeData.
  • When a companion (or any unit) ascends, EyeData is found (if any) for the companion and placed in front of their sprites.

Example

//'this' refers to an instance of the WildfrostMod class.
//assets is a list of objects used in Tutorial 2 and onward.

assets.Add( new EyeDataBuilder(this)
    .Create("theeyesofwort")
    .WithCardData("Wort")
    .WithEyes( new Eye()
        {
            postion = new Vector2(0.5f,0.5f),
            scale = new Vector2(1.0f,1.0f),
            rotation = 22.5f
        }, 
        new Eye()
        {
            postion = new Vector2(-0.5f,0.5f),
            scale = new Vector2(1.0f,1.0f),
            rotation = 22.5f
        })
    );

//Note that for the builder to actually build the EyeData, an AddAssets method needs to be written. See Tutorial 2 for the code.

Simplification

The EyeDataBuilder is simple enough that it can be simplified to a single method. The method is written as an extension method, but can be rewritten however you want.

public static EyeDataBuilder CreateEyeDataBuilder(WildfrostMod mod, string cardName, params (float, float, float, float, float)[] eyes)
{
    string trueName = mod.GUID + "." + cardName;
    EyeData.Eye[] trueEyes = eyes.Select( e => new EyeData.Eye()
        {
            position = new Vector2(e.Item1, e.Item2),
            scale = new Vector2(e.Item3, e.Item4),
            rotation = e.Item5
        } ).ToArray();
    return new EyeDataBuilder(mod)
        .Create("EyesOf" + trueName)
        .WithCardData(trueName)
        .WithEyes(trueEyes);
}

This makes the earlier example into this:

assets.Add( CreateEyeDataBuilder(this, "Wort",
    ( 0.5f, 0.5f, 1.0f, 1.0f, 22.5f),
    (-0.5f, 0.5f, 1.0f, 1.0f, 22.5f)
    ));

Methods

Create (Inherited from DataFileBuilder)

Create(string name)

  • Used to create an empty EyeData.
  • name is the internal name for your EyeData.

WithCardData

WithCardData(string cardData) or WithCardData(CardData cardData)

  • Used to specify which card the EyeData belongs to.
  • cardData is either the internal name of the card or the CardData itself.

WithEyes

WithEyes(params EyeData.Eye[] eyes)

  • Used to set the eyes used by the EyeData.
  • eyes have the following properties
    • position: A Vector2 that determines where on the card the eye goes. Typically, the first coordinate is between 0 and 1, and the second is between -1 and 1.
    • scale: A Vector2 that determines how tall or wide the eye is. Both coordinates are typically around or less than 1.
    • rotation: A float that determines the rotation of the eye (in degrees). 0 degrees corresponds to a diamond.