public static bool Prefix(bool _debugPrints, string _savePath) { ItemSerializer.savePath = _savePath; ItemSerializer.debugPrints = true; List <PlaceableItem> originalItemList = new List <PlaceableItem>(Singleton <BuildingController> .Instance.allItemsArray.array); List <PlaceableItem> itemsUsingDefaultSerializationSystem = new List <PlaceableItem>(); List <PlaceableItem> itemsUsingCustomSerializationSystem = new List <PlaceableItem>(); foreach (PlaceableItem pl in originalItemList) { if (pl == null) { continue; } bool isModded = ActivePlaceableItemCreators.HasCreatorFromEnum(pl.itemType); bool usesCustomSerializer = ActivePlaceableItemCreators.GetCreatorFromEnum(pl.itemType) is IACMFPlaceableItemCustomSerializationSystem; if (isModded && usesCustomSerializer) { itemsUsingCustomSerializationSystem.Add(pl); } else { itemsUsingDefaultSerializationSystem.Add(pl); } } DynamicArray <PlaceableItem> itemsToUseDefaultSerialisationBehaviour = new DynamicArray <PlaceableItem>(256); itemsToUseDefaultSerialisationBehaviour.AddRange(itemsUsingDefaultSerializationSystem.ToArray()); ItemSerializer.SerializeItems(itemsToUseDefaultSerialisationBehaviour); PlaceableItemSerializer.SerializePlaceableItemsUsingCustomSerializationSystem(ItemSerializer.savePath, itemsUsingCustomSerializationSystem); return(false); }
public static void Postfix(bool _debugPrints, string _savePath) { PlaceableItemSerializer.DeserializePlaceableItemsUsingCustomSerializationSystem(_savePath); }