Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Optimize memory usage and load speed of cultural properties by reducing data duplication (see comment) #104

@Zematus

Description

@Zematus

Just as an example, see this FinalizeLoad code in CulturalSkillInfo:

public virtual void FinalizeLoad()
{
    if (Id.Contains(BiomeSurvivalSkill.SkillIdPrefix))
    {
        string idSuffix = Id.Substring(BiomeSurvivalSkill.SkillIdPrefix.Length);
        Biome biome = Biome.Biomes[idSuffix.Replace('_', ' ')];

        Name = BiomeSurvivalSkill.GenerateName(biome);
        RngOffset = BiomeSurvivalSkill.GenerateRngOffset(biome);
    }
    else
    {
        switch (Id)
        {
            case SeafaringSkill.SkillId:
                Name = SeafaringSkill.SkillName;
                RngOffset = SeafaringSkill.SkillRngOffset;
                break;

            default:
                throw new System.Exception("Unhandled Skill Id: " + Id);
        }
    }
}

This method is being called when loading each skill on each group but most of what it does is duplicate data that should be shared by all Cultural Skills of the same type (Name, Id, RngOffset)

A solution would be to store a common CulturalSkillInfo object that all CulturalSkill objects with the same Id refer to.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions