My approach

I know it’s the same thing, but I used a constructor in PartyMember rather than detail it all in our loop, moving all the reference assignations into the constructor and passing in the specific PartyMemberInfo.

    public PartyMember(PartyMemberInfo memberInfo)
    {
        MemberName = memberInfo.MemberName;
        Level = memberInfo.StartingLevel;
        CurrentHealth = memberInfo.BaseHealth;
        MaxHealth = memberInfo.BaseHealth;
        Strength = memberInfo.BaseStr;
        Initiative = memberInfo.BaseInitiative;
        MemberBattleVisualPrefab = memberInfo.MemberBattleVisualPrefab;
        MemberOverworldVisualPrefab = memberInfo.MemberOverworldVisualPrefab;
    }

I also added a “break;” after adding the newPartyMember to the currentParty list so that the loop wouldn’t continue.

4 Likes

I also wondered the same, if the use of the constructor wouldn’t be the better solution as it wouldn’t hurt the integrity of “public variables”. It works nontheless. :slight_smile:

2 Likes

I agree that this is a much better approach. A similar one would be to have the field-initialization handled by a static method.

Privacy & Terms