Talents = new List(); protected override void PopulateData(ParsedDataList data) { if (data.TryGetParsedData(0, out var talentsData)) { EasyParser.ParseSubRowsData(talentsData, Talents, (row, subRow, index) => { var talent = new Talent { Id = talentsData.GetString(row, 0), Name = talentsData.GetString(row, 1), Chance = talentsData.GetFloat(row, 2), Cooldown = talentsData.GetFloat(row, 3), Duration = talentsData.GetFloat(row, 4), Cost = talentsData.GetInt(row, 5), Actions = talentsData.GetEnumList(row, 6), Conditions = new List(), "> Talents = new List(); protected override void PopulateData(ParsedDataList data) { if (data.TryGetParsedData(0, out var talentsData)) { EasyParser.ParseSubRowsData(talentsData, Talents, (row, subRow, index) => { var talent = new Talent { Id = talentsData.GetString(row, 0), Name = talentsData.GetString(row, 1), Chance = talentsData.GetFloat(row, 2), Cooldown = talentsData.GetFloat(row, 3), Duration = talentsData.GetFloat(row, 4), Cost = talentsData.GetInt(row, 5), Actions = talentsData.GetEnumList(row, 6), Conditions = new List(), "> Talents = new List(); protected override void PopulateData(ParsedDataList data) { if (data.TryGetParsedData(0, out var talentsData)) { EasyParser.ParseSubRowsData(talentsData, Talents, (row, subRow, index) => { var talent = new Talent { Id = talentsData.GetString(row, 0), Name = talentsData.GetString(row, 1), Chance = talentsData.GetFloat(row, 2), Cooldown = talentsData.GetFloat(row, 3), Duration = talentsData.GetFloat(row, 4), Cost = talentsData.GetInt(row, 5), Actions = talentsData.GetEnumList(row, 6), Conditions = new List(), ">
[CreateAssetMenu(menuName = "Create TalentsDatabase", fileName = "TalentsDatabase", order = 0)]
public class TalentsDatabase : ParsedScriptableObject
{
    public List<Talent> Talents = new List<Talent>();
    protected override void PopulateData(ParsedDataList data)
    {
        if (data.TryGetParsedData(0, out var talentsData))
        {
            EasyParser.ParseSubRowsData(talentsData, Talents, (row, subRow, index) =>
            {
                var talent = new Talent
                {
                    Id = talentsData.GetString(row, 0),
                    Name = talentsData.GetString(row, 1),
                    Chance = talentsData.GetFloat(row, 2),
                    Cooldown = talentsData.GetFloat(row, 3),
                    Duration = talentsData.GetFloat(row, 4),
                    Cost = talentsData.GetInt(row, 5),
                    Actions = talentsData.GetEnumList<ActionType>(row, 6),
                    Conditions = new List<Condition>(),
                    Effects = new List<Effect>()
                };
                if (subRow)
                {
                    talent = Talents[index];
                    talent.Conditions.Add(new Condition
                    {
                        Type = talentsData.GetEnum<ConditionType>( row, 7),
                        Value = talentsData.GetFloat(row, 8)
                    });
                    talent.Effects.Add(new Effect
                    {
                        Type = talentsData.GetEnum<EffectType>( row, 9),
                        Value = talentsData.GetFloat(row, 10)
                    });
                }
                return talent;
            });
        }
    }
}

Explanation of TalentsDatabase and SubRows

The TalentsDatabase class is designed to handle a more complex data structure where some rows represent primary data (e.g., talent definitions) and others represent additional sub-data (e.g., conditions and effects associated with those talents). This is achieved using the EasyParser.ParseSubRowsData method, which is specifically tailored for handling sub-rows.


What are SubRows?

  • Definition:

    • In a tabular data structure, sub-rows are rows that belong to and extend the information of a parent row (main row).
    • They typically represent additional details or related data that cannot be fully captured in a single row for the parent entity.
  • Example Data:

    Row 0: "talent_1", "Fireball", 0.8, 10, 5, 50, "Attack", "", "", ""
    Row 1: "", "", "", "", "", "", "", "Burn", 20, "Damage"
    Row 2: "", "", "", "", "", "", "", "Slow", 10, "Movement"
    Row 3: "talent_2", "Ice Blast", 0.7, 12, 6, 40, "Debuff", "", "", ""
    Row 4: "", "", "", "", "", "", "", "Freeze", 15, "Movement"
    
    
    • Row 0: Main talent definition (talent_1).
    • Row 1 and Row 2: Sub-rows containing Conditions and Effects for talent_1.
    • Row 3: Main talent definition (talent_2).
    • Row 4: Sub-row for talent_2.

How SubRows Work in TalentsDatabase

The EasyParser.ParseSubRowsData method processes data rows and dynamically determines whether a row is a main row (a new talent) or a sub-row (additional conditions and effects for an existing talent). Here’s how the logic works step-by-step:


Workflow

  1. Parsing the Data
    • The ParseSubRowsData method iterates through each row in talentsData.

  1. Identifying SubRows

    if (subRow)
    
    • The subRow flag is used to check if the current row is a sub-row:
      • If the first column (Id) is empty or invalid, it is treated as a sub-row.
      • Otherwise, it is treated as a main row.

  1. Processing Main Rows

    var talent = new Talent
    {
        Id = talentsData.GetString(row, 0),
        Name = talentsData.GetString(row, 1),
        Chance = talentsData.GetFloat(row, 2),
        Cooldown = talentsData.GetFloat(row, 3),
        Duration = talentsData.GetFloat(row, 4),
        Cost = talentsData.GetInt(row, 5),
        Actions = talentsData.GetEnumList<ActionType>(row, 6),
        Conditions = new List<Condition>(),
        Effects = new List<Effect>()
    };
    
    • For main rows:
      • A new Talent object is created using the primary columns (e.g., IdNameChance).
      • The Conditions and Effects lists are initialized as empty.
      • This Talent is added to the Talents list.

  1. Processing SubRows

    talent = Talents[index];
    talent.Conditions.Add(new Condition
    {
        Type = talentsData.GetEnum<ConditionType>( row, 7),
        Value = talentsData.GetFloat(row, 8)
    });
    talent.Effects.Add(new Effect
    {
        Type = talentsData.GetEnum<EffectType>( row, 9),
        Value = talentsData.GetFloat(row, 10)
    });
    
    • For sub-rows:
      • The method retrieves the most recent talent object (Talents[index]).
      • Parses the Condition and Effect columns.
      • Adds the parsed Condition and Effect objects to the talent's respective lists.