Exemplo n.º 1
0
    private void OnSerializing()
    {
        List <Element> elements = ElementLoader.elements;
        Diseases       diseases = Db.Get().Diseases;

        serializedParticleProperties = new List <SerializedParticleProperties>();
        foreach (ParticleProperties particleProperty in particleProperties)
        {
            ParticleProperties           current = particleProperty;
            SerializedParticleProperties item    = default(SerializedParticleProperties);
            item.elementID    = elements[current.elementIdx].id;
            item.diseaseID    = ((current.diseaseIdx == 255) ? HashedString.Invalid : diseases[current.diseaseIdx].IdHash);
            item.mass         = current.mass;
            item.temperature  = current.temperature;
            item.diseaseCount = current.diseaseCount;
            serializedParticleProperties.Add(item);
        }
    }
Exemplo n.º 2
0
 private void OnDeserialized()
 {
     if (serializedParticleProperties != null)
     {
         Diseases diseases = Db.Get().Diseases;
         particleProperties.Clear();
         foreach (SerializedParticleProperties serializedParticleProperty in serializedParticleProperties)
         {
             SerializedParticleProperties current = serializedParticleProperty;
             ParticleProperties           item    = default(ParticleProperties);
             item.elementIdx   = (byte)ElementLoader.GetElementIndex(current.elementID);
             item.diseaseIdx   = (byte)((!(current.diseaseID != HashedString.Invalid)) ? 255 : diseases.GetIndex(current.diseaseID));
             item.mass         = current.mass;
             item.temperature  = current.temperature;
             item.diseaseCount = current.diseaseCount;
             particleProperties.Add(item);
         }
     }
     else
     {
         particleProperties = properties;
     }
     properties = null;
 }