Beispiel #1
0
    // Deserialize and check Est Entries and add them to the list if they are non-default.
    private void DeserializeEstEntries(MetaFileInfo metaFileInfo, byte[]?data)
    {
        if (data == null)
        {
            return;
        }

        var num = data.Length / 6;

        using var reader = new BinaryReader(new MemoryStream(data));
        for (var i = 0; i < num; ++i)
        {
            var gr    = ( GenderRace )reader.ReadUInt16();
            var id    = reader.ReadUInt16();
            var value = reader.ReadUInt16();
            var type  = (metaFileInfo.SecondaryType, metaFileInfo.EquipSlot) switch
            {
                (BodySlot.Face, _) => EstManipulation.EstType.Face,
                (BodySlot.Hair, _) => EstManipulation.EstType.Hair,
                (_, EquipSlot.Head) => EstManipulation.EstType.Head,
                (_, EquipSlot.Body) => EstManipulation.EstType.Body,
                _ => (EstManipulation.EstType) 0,
            };
            if (!gr.IsValid() || type == 0)
            {
                continue;
            }

            var def = EstFile.GetDefault(type, gr, id);
            if (def != value)
            {
                MetaManipulations.Add(new EstManipulation(gr.Split().Item1, gr.Split().Item2, type, id, value));
            }
        }
Beispiel #2
0
        public bool RevertMod(EstManipulation m)
        {
#if USE_EST
            if (Manipulations.Remove(m))
            {
                var def   = EstFile.GetDefault(m.Slot, Names.CombinedRace(m.Gender, m.Race), m.SetId);
                var manip = new EstManipulation(m.Gender, m.Race, m.Slot, m.SetId, def);
                var file  = m.Slot switch
                {
                    EstManipulation.EstType.Hair => HairFile !,
                    EstManipulation.EstType.Face => FaceFile !,
                    EstManipulation.EstType.Body => BodyFile !,
                    EstManipulation.EstType.Head => HeadFile !,
                    _ => throw new ArgumentOutOfRangeException(),
                };
                return(manip.Apply(file));
            }
#endif
            return(false);
        }