Mutagen-Modding / Mutagen

A .NET library for analyzing, creating, and manipulating Bethesda mods
GNU General Public License v3.0
117 stars 32 forks source link

ItemOrList init setting documentation #518

Open Noggog opened 4 months ago

Noggog commented 4 months ago

For example:

Condition AmuletCondition = new ConditionFloat {
  Data = new GetEquippedConditionData {
    RunOnType = Condition.RunOnType.Reference,
    Reference = Skyrim.PlayerRef,
    ItemOrList = AmuletOfArticulationFormList, // won't work
  },
  CompareOperator = CompareOperator.EqualTo,
  ComparisonValue = 1
};

A potential fix:

    public IFormLink<IItemOrListGetter> ItemOrListLink
    {
      init
      {
        this._ItemOrList.Link.SetTo<IItemOrListGetter>((IFormLink<IItemOrListGetter>) value);
      }
    }

Adding "extra" properties wasn't on the radar, as it messes with other tooling that wants to investigate an object via reflection. But a set only property might avoid most of those problems

Elscrux commented 1 month ago

We didn't find a better way back then but now I see that this is actually valid syntax for this scenario!

Condition AmuletCondition = new ConditionFloat {
    Data = new GetEquippedConditionData {
        RunOnType = Condition.RunOnType.Reference,
        Reference = Skyrim.PlayerRef,
        ItemOrList = {
            Link = {
                FormKey = Skyrim.FormList.TGAmuletofArticulationList.FormKey
            }
        },
    },
    CompareOperator = CompareOperator.EqualTo,
    ComparisonValue = 1
};

I think we can probably close this?

Noggog commented 1 month ago

Sounds good. Maybe we convert this card to a documentation card. Can't imagine many people will discover that on their own, so might be good to slide into the docs somewhere

Elscrux commented 1 month ago

Just a note: this is not only about ItemOrList but any condition parameters using FormLinkOrIndex