using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

namespace Logic {
    public class ActionListConverter : JsonConverter {

        public override bool CanConvert(Type objectType) {
            return typeof(ConditionList).IsAssignableFrom(objectType);
        }

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
            return ActionList.DeserializeCompact(serializer.Deserialize<string>(reader));
        }

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
            serializer.Serialize(writer, (value as ActionList).SerializeCompact());
        }
    }
}