TESVSnip.Domain.Model.Plugin.GetNewFormID C# (CSharp) Method

GetNewFormID() public method

public GetNewFormID ( bool increment = false ) : uint
increment bool
return uint
        public uint GetNewFormID(bool increment = false)
        {
            uint formID = 0;
            var tes4 = this.Records.OfType<Record>().FirstOrDefault(x => x.Name .StartsWith("TES"));
            if (tes4 != null && tes4.SubRecords.Count > 0)
            {
                var masterCount = tes4.SubRecords.Count(x => x.Name == "MAST");
                var hedr = tes4.SubRecords[0];
                if (hedr.Name == "HEDR" && hedr.Size >= 12)
                {
                    if (hedr.TryGetValue(8, out formID) && increment)
                    {
                        hedr.TrySetValue(8, (formID & 0x00FFFFFF) + 1);
                    }
                }
                return (formID & 0x00FFFFFF) | ((uint)(masterCount << 24));
            }
            return formID;
        }