public static List <VanillaAmmoData> RipOutWhere(List <VanillaAmmoData> original, Predicate <VanillaAmmoData> pred, bool doRip = true) { var newData = new VanillaAmmoData[original.Count]; for (int i = original.Count - 1; i >= 0; i--) { if (pred(original[i])) { newData[i] = original[i]; if (doRip) { original[i] = new AmmoDataV02() { count = 0, emotionData = new SlimeEmotionDataV02() { emotionData = new Dictionary <SlimeEmotions.Emotion, float>() }, id = Identifiable.Id.NONE } } ; } } return(newData.ToList()); }
public void Read(BinaryReader reader) { version = reader.ReadInt32(); modid = reader.ReadString(); byteLength = reader.ReadInt64(); if (!(SRModLoader.GetMod(modid) is SRMod mod)) { throw new Exception($"Unrecognized mod id: {modid}"); } var saveInfo = SaveRegistry.GetSaveInfo(mod); identifiableData.Clear(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { var e = new IdentifiedData(); e.Read(reader, saveInfo); identifiableData.Add(e); } extendedData.Clear(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { var e = new ExtendedDataTree(); e.Read(reader); extendedData.Add(e); } if (version >= 1) { playerData.Read(reader); pediaData.Read(reader); enumTranslator = new EnumTranslator(); enumTranslator.Read(reader); BinaryUtils.ReadDictionary(reader, customAmmo, (x) => AmmoIdentifier.Read(x), (x) => { var list = new List <VanillaAmmoData>(); int ammoCount = x.ReadInt32(); for (int i = 0; i < ammoCount; i++) { if (x.ReadBoolean()) { var newData = new VanillaAmmoData(); newData.Load(x.BaseStream); list.Add(newData); } else { list.Add(null); } } return(list); }); } }