Beispiel #1
0
    public static bool NPDT(PropertyInfo property, object currentParam, object firstParam, object nextParam)
    {
        // Get the values as their correct type.
        var current = property.GetValue(currentParam) as NPDT
                      ?? throw new ArgumentException("Current record is of incorrect type.");
        var first = property.GetValue(firstParam) as NPDT
                    ?? throw new ArgumentException("First record is of incorrect type.");
        var next = property.GetValue(nextParam) as NPDT
                   ?? throw new ArgumentException("Next record is of incorrect type.");

        var modified = false;

        // Perform basic merges.
        if (RecordMerger.MergeNamedProperties(NPCDataBasicProperties, current, first, next))
        {
            modified = true;
        }

        // Ensure that we always have skills, in case that we change the autocalc flag.
        if (current.Skills is null && next.Skills is not null)
        {
            current.Skills = next.Skills;
            modified       = true;
        }

        // element-wise merge
        if (current.Skills is not null && next.Skills is not null)
        {
            if (current.Skills.SequenceEqual(next.Skills))
            {
                return(modified);
            }
            if (first.Skills is null)
            {
                first.Skills = next.Skills;
                modified     = true;
            }
            // TODO length check

            for (var i = 0; i < current.Skills.Length; i++)
            {
                var skill      = current.Skills[i];
                var firstSkill = first.Skills[i];
                var nextSkill  = next.Skills[i];

                var currentIsModified = firstSkill != skill;
                var nextIsModified    = firstSkill != nextSkill;

                if (!currentIsModified && nextIsModified)
                {
                    current.Skills[i] = nextSkill;
                }
            }
        }
        return(modified);
    }
Beispiel #2
0
    public static bool CLDT(PropertyInfo property, object currentParam, object firstParam, object nextParam)
    {
        // Get the values as their correct type.
        var current = property.GetValue(currentParam) as TES3Lib.Subrecords.CLAS.CLDT ?? throw new ArgumentException("Current record is of incorrect type.");
        var first   = property.GetValue(firstParam) as TES3Lib.Subrecords.CLAS.CLDT ?? throw new ArgumentException("First record is of incorrect type.");
        var next    = property.GetValue(nextParam) as TES3Lib.Subrecords.CLAS.CLDT ?? throw new ArgumentException("Next record is of incorrect type.");

        bool modified = false;

        // Perform basic merges.
        if (RecordMerger.MergeNamedProperties(ClassDataBasicProperties, current, first, next))
        {
            modified = true;
        }

        return(modified);
    }