Exemplo n.º 1
0
 public static void WriteJson <T>(this ZergRush.ReactiveCore.ReactiveCollection <T> self, JsonTextWriter writer) where T : ZergRush.Alive.Livable, ILivableModification, IHashable
 {
     writer.WriteStartArray();
     for (int i = 0; i < self.Count; i++)
     {
         self[i].WriteJson(writer);
     }
     writer.WriteEndArray();
 }
Exemplo n.º 2
0
 public static void WriteJson(this ZergRush.ReactiveCore.ReactiveCollection <Game.RocketInstance> self, JsonTextWriter writer)
 {
     writer.WriteStartArray();
     for (int i = 0; i < self.Count; i++)
     {
         self[i].WriteJson(writer);
     }
     writer.WriteEndArray();
 }
Exemplo n.º 3
0
    public static ulong CalculateHash <T>(this ZergRush.ReactiveCore.ReactiveCollection <T> self) where T : ZergRush.Alive.Livable, ILivableModification, IHashable
    {
        System.UInt64 hash = 345093625;
        hash += (ulong)590981122;
        hash += hash << 11; hash ^= hash >> 7;
        var size = self.Count;

        for (int i = 0; i < size; i++)
        {
            hash += self[i].CalculateHash();
            hash += hash << 11; hash ^= hash >> 7;
        }
        return(hash);
    }
Exemplo n.º 4
0
 public static void ReadFromJson <T>(this ZergRush.ReactiveCore.ReactiveCollection <T> self, JsonTextReader reader) where T : ZergRush.Alive.Livable, ILivableModification, IHashable
 {
     if (reader.TokenType != JsonToken.StartArray)
     {
         throw new JsonSerializationException("Bad Json Format");
     }
     while (reader.Read())
     {
         if (reader.TokenType == JsonToken.EndArray)
         {
             break;
         }
         self.Add(null);
         self[self.Count - 1] = (T)ZergRush.Alive.Livable.CreatePolymorphic(reader.ReadJsonClassId());
         self[self.Count - 1].ReadFromJson(reader);
     }
 }
Exemplo n.º 5
0
    public static void CompareCheck <T>(this ZergRush.ReactiveCore.ReactiveCollection <T> self, ZergRush.ReactiveCore.ReactiveCollection <T> other, Stack <string> path) where T : ZergRush.Alive.Livable, ILivableModification, IHashable
    {
        if (self.Count != other.Count)
        {
            SerializationTools.LogCompError(path, "Count", other.Count, self.Count);
        }
        var count = Math.Min(self.Count, other.Count);

        for (int i = 0; i < count; i++)
        {
            if (SerializationTools.CompareClassId(path, i.ToString(), self[i], other[i]))
            {
                path.Push(i.ToString());
                self[i].CompareCheck(other[i], path);
                path.Pop();
            }
        }
    }
Exemplo n.º 6
0
 public static void ReadFromJson(this ZergRush.ReactiveCore.ReactiveCollection <Game.RocketInstance> self, JsonTextReader reader)
 {
     if (reader.TokenType != JsonToken.StartArray)
     {
         throw new JsonSerializationException("Bad Json Format");
     }
     while (reader.Read())
     {
         if (reader.TokenType == JsonToken.EndArray)
         {
             break;
         }
         Game.RocketInstance val = default;
         val = new Game.RocketInstance();
         val.ReadFromJson(reader);
         self.Add(val);
     }
 }
Exemplo n.º 7
0
 public static List <T> ToList <T>(this ReactiveCollection <T> coll)
 {
     return(coll.AsEnumerable().ToList());
 }