Ejemplo n.º 1
0
 public void InitProxy()
 {
     if (GameSetup.IsNewGame)
     {
         int num = Mathf.Min(this._proxy._greebleZones.Length, this._greebleZonesData.Length);
         for (int i = 0; i < num; i++)
         {
             GreebleZone greebleZone = this._proxy._greebleZones[i];
             if (greebleZone)
             {
                 GreebleZonesManager.GZData gzdata = this._greebleZonesData[i];
                 if (gzdata == null)
                 {
                     gzdata = (this._greebleZonesData[i] = new GreebleZonesManager.GZData());
                 }
                 int maxInstancesModified = this._proxy._greebleZones[i].MaxInstancesModified;
                 if (gzdata._instancesState == null || gzdata._instancesState.Length != maxInstancesModified)
                 {
                     gzdata._instancesState = new byte[maxInstancesModified];
                     for (int j = 0; j < gzdata._instancesState.Length; j++)
                     {
                         gzdata._instancesState[j] = 254;
                     }
                 }
                 greebleZone.Data       = this._greebleZonesData[i];
                 greebleZone.Data.GZ    = greebleZone;
                 greebleZone.Data.GZMid = i;
             }
         }
     }
     else
     {
         this.OnDeserializedProxy();
     }
 }
Ejemplo n.º 2
0
 private void OnDeserialized()
 {
     if (this._savedVersion == this._currentVersion)
     {
         if (this._greebleZonesData.Length != this._zoneCount)
         {
             if (this._greebleZonesData.Length <= this._zoneCount)
             {
                 this.RefreshGreebleZones();
                 return;
             }
             List <GreebleZonesManager.GZData> list = this._greebleZonesData.ToList <GreebleZonesManager.GZData>();
             list.RemoveRange(this._zoneCount, this._greebleZonesData.Length - this._zoneCount);
             this._greebleZonesData = list.ToArray();
         }
         for (int i = 0; i < this._zoneCount; i++)
         {
             GreebleZonesManager.GZData gZData = this._greebleZonesData[i];
             if (gZData == null)
             {
                 gZData = (this._greebleZonesData[i] = new GreebleZonesManager.GZData());
                 gZData._instancesState = new byte[this._greebleZones[i].MaxInstances];
                 for (int j = 0; j < gZData._instancesState.Length; j++)
                 {
                     gZData._instancesState[j] = 254;
                 }
             }
             else
             {
                 GreebleZone greebleZone = this._greebleZones[i];
                 if (greebleZone)
                 {
                     if (gZData._instancesState.Length != greebleZone.MaxInstances)
                     {
                         gZData._instancesState = new byte[greebleZone.MaxInstances];
                         for (int k = 0; k < gZData._instancesState.Length; k++)
                         {
                             gZData._instancesState[k] = 254;
                         }
                     }
                     greebleZone.Data = gZData;
                     gZData.GZ        = greebleZone;
                     gZData.GZMid     = i;
                 }
             }
         }
     }
     else if (!Scene.Atmosphere.InACave)
     {
         Debug.Log("Clearing up deprecated saved greeble data");
         this.RefreshGreebleZones();
     }
     else
     {
         Debug.Log("Greeble data out of sync. Restoring not handled in caves.");
     }
 }
Ejemplo n.º 3
0
    private void OnSerializing()
    {
        int num = Mathf.Min(new int[]
        {
            this._zoneCount,
            this._greebleZones.Length,
            this._greebleZonesData.Length
        });

        for (int i = 0; i < num; i++)
        {
            GreebleZone greebleZone           = this._greebleZones[i];
            GreebleZonesManager.GZData gZData = this._greebleZonesData[i];
            if (greebleZone && greebleZone.CurrentlyVisible && gZData != null && gZData._instancesState != null && gZData._instancesState.Length == greebleZone.Instances.Length)
            {
                int j;
                for (j = 0; j < greebleZone.Instances.Length; j++)
                {
                    if (greebleZone.Instances[j])
                    {
                        if (gZData._instancesState[j] > 252)
                        {
                            gZData._instancesState[j] = 253;
                        }
                    }
                    else
                    {
                        gZData._instancesState[j] = 255;
                    }
                }
                while (j < this._greebleZones[i].MaxInstances)
                {
                    gZData._instancesState[j] = 254;
                    j++;
                }
            }
            else if (greebleZone && gZData == null)
            {
                gZData = (this._greebleZonesData[i] = new GreebleZonesManager.GZData());
                gZData._instancesState = new byte[greebleZone.MaxInstances];
                for (int k = 0; k < gZData._instancesState.Length; k++)
                {
                    gZData._instancesState[k] = 254;
                }
            }
        }
        this._savedVersion = this._currentVersion;
    }
Ejemplo n.º 4
0
 private void Awake()
 {
     if (!LevelSerializer.IsDeserializing)
     {
         for (int i = 0; i < this._zoneCount; i++)
         {
             GreebleZone greebleZone = this._greebleZones[i];
             if (greebleZone)
             {
                 greebleZone.Data       = this._greebleZonesData[i];
                 greebleZone.Data.GZ    = greebleZone;
                 greebleZone.Data.GZMid = i;
             }
         }
     }
 }
Ejemplo n.º 5
0
 private void OnDeserializedNonProxied()
 {
     if (this._greebleZonesData.Length == this._zoneCount)
     {
         int num = this._zoneCount - this._nonProxiedZones.Length;
         for (int i = 0; i < this._nonProxiedZones.Length; i++)
         {
             GreebleZonesManager.GZData gzdata = this._greebleZonesData[i + num];
             if (gzdata == null)
             {
                 gzdata = (this._greebleZonesData[i + num] = new GreebleZonesManager.GZData());
                 gzdata._instancesState = new byte[this._nonProxiedZones[i].MaxInstancesModified];
                 for (int j = 0; j < gzdata._instancesState.Length; j++)
                 {
                     gzdata._instancesState[j] = 254;
                 }
             }
             else
             {
                 GreebleZone greebleZone = this._nonProxiedZones[i];
                 if (greebleZone)
                 {
                     if (gzdata._instancesState.Length != greebleZone.MaxInstancesModified)
                     {
                         gzdata._instancesState = new byte[greebleZone.MaxInstancesModified];
                         for (int k = 0; k < gzdata._instancesState.Length; k++)
                         {
                             gzdata._instancesState[k] = 254;
                         }
                     }
                     greebleZone.Data = gzdata;
                     gzdata.GZ        = greebleZone;
                     gzdata.GZMid     = i;
                     if (greebleZone.RandomSeed != 0)
                     {
                         gzdata._seed = -1;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
    private void InitNonProxied()
    {
        int num = this._zoneCount - this._nonProxiedZones.Length;

        for (int i = 0; i < this._nonProxiedZones.Length; i++)
        {
            GreebleZone greebleZone = this._nonProxiedZones[i];
            if (greebleZone)
            {
                if (this._greebleZonesData[i + num] == null)
                {
                    GreebleZonesManager.GZData gzdata = this._greebleZonesData[i + num] = new GreebleZonesManager.GZData();
                    gzdata._instancesState = new byte[this._nonProxiedZones[i].MaxInstancesModified];
                    for (int j = 0; j < gzdata._instancesState.Length; j++)
                    {
                        gzdata._instancesState[j] = 254;
                    }
                }
                greebleZone.Data       = this._greebleZonesData[i + num];
                greebleZone.Data.GZ    = greebleZone;
                greebleZone.Data.GZMid = i;
            }
        }
    }
Ejemplo n.º 7
0
 private void OnDeserializedProxy()
 {
     if (this._savedVersion == this._proxy._currentVersion)
     {
         if (this._greebleZonesData.Length != this._zoneCount)
         {
             if (this._greebleZonesData.Length <= this._zoneCount)
             {
                 this.RefreshGreebleZones();
                 return;
             }
             List <GreebleZonesManager.GZData> list = this._greebleZonesData.ToList <GreebleZonesManager.GZData>();
             list.RemoveRange(this._zoneCount, this._greebleZonesData.Length - this._zoneCount);
             this._greebleZonesData = list.ToArray();
         }
         int num = Mathf.Min(new int[]
         {
             this._zoneCount,
             this._proxy._greebleZones.Length,
             this._greebleZonesData.Length
         });
         for (int i = 0; i < num; i++)
         {
             GreebleZonesManager.GZData gzdata = this._greebleZonesData[i];
             if (gzdata == null)
             {
                 gzdata = (this._greebleZonesData[i] = new GreebleZonesManager.GZData());
                 gzdata._instancesState = new byte[this._proxy._greebleZones[i].MaxInstancesModified];
                 for (int j = 0; j < gzdata._instancesState.Length; j++)
                 {
                     gzdata._instancesState[j] = 254;
                 }
             }
             else
             {
                 GreebleZone greebleZone = this._proxy._greebleZones[i];
                 if (greebleZone)
                 {
                     if (gzdata._instancesState.Length != greebleZone.MaxInstancesModified)
                     {
                         gzdata._instancesState = new byte[greebleZone.MaxInstancesModified];
                         for (int k = 0; k < gzdata._instancesState.Length; k++)
                         {
                             gzdata._instancesState[k] = 254;
                         }
                     }
                     greebleZone.Data = gzdata;
                     gzdata.GZ        = greebleZone;
                     gzdata.GZMid     = i;
                     if (greebleZone.RandomSeed != 0)
                     {
                         gzdata._seed = -1;
                     }
                 }
             }
         }
     }
     else if (!LocalPlayer.IsInCaves)
     {
         Debug.Log("Clearing up deprecated saved greeble data");
         this.RefreshGreebleZones();
     }
     else
     {
         Debug.Log("Greeble data out of sync. Restoring not handled in caves.");
     }
 }
Ejemplo n.º 8
0
 private void OnSerializing()
 {
     if (this._proxy)
     {
         int num = Mathf.Min(new int[]
         {
             this._zoneCount,
             this._proxy._greebleZones.Length,
             this._greebleZonesData.Length
         });
         int i;
         for (i = 0; i < num; i++)
         {
             GreebleZone greebleZone           = this._proxy._greebleZones[i];
             GreebleZonesManager.GZData gzdata = this._greebleZonesData[i];
             if (greebleZone && greebleZone.CurrentlyVisible && gzdata != null && gzdata._instancesState != null && gzdata._instancesState.Length == greebleZone.Instances.Length)
             {
                 int j;
                 for (j = 0; j < greebleZone.Instances.Length; j++)
                 {
                     if (greebleZone.Instances[j])
                     {
                         if (gzdata._instancesState[j] > 252)
                         {
                             gzdata._instancesState[j] = 253;
                         }
                         else if (gzdata._instancesState[j] == 252)
                         {
                             CustomActiveValueGreeble component = greebleZone.Instances[j].GetComponent <CustomActiveValueGreeble>();
                             if (component)
                             {
                                 component.UpdateGreebleData();
                             }
                         }
                     }
                     else
                     {
                         gzdata._instancesState[j] = byte.MaxValue;
                     }
                 }
                 int maxInstancesModified = this._proxy._greebleZones[i].MaxInstancesModified;
                 while (j < maxInstancesModified)
                 {
                     gzdata._instancesState[j] = 254;
                     j++;
                 }
             }
             else if (greebleZone && gzdata == null)
             {
                 gzdata = (this._greebleZonesData[i] = new GreebleZonesManager.GZData());
                 gzdata._instancesState = new byte[greebleZone.MaxInstancesModified];
                 for (int k = 0; k < gzdata._instancesState.Length; k++)
                 {
                     gzdata._instancesState[k] = 254;
                 }
             }
         }
         for (int l = 0; l < this._nonProxiedZones.Length; l++)
         {
             GreebleZone greebleZone2           = this._nonProxiedZones[l];
             GreebleZonesManager.GZData gzdata2 = this._greebleZonesData[i];
             if (greebleZone2 && greebleZone2.CurrentlyVisible && gzdata2 != null && gzdata2._instancesState != null && gzdata2._instancesState.Length == greebleZone2.Instances.Length)
             {
                 int m;
                 for (m = 0; m < greebleZone2.Instances.Length; m++)
                 {
                     if (greebleZone2.Instances[m])
                     {
                         if (gzdata2._instancesState[m] > 252)
                         {
                             gzdata2._instancesState[m] = 253;
                         }
                         else if (gzdata2._instancesState[m] == 252)
                         {
                             CustomActiveValueGreeble component2 = greebleZone2.Instances[m].GetComponent <CustomActiveValueGreeble>();
                             if (component2)
                             {
                                 component2.UpdateGreebleData();
                             }
                         }
                     }
                     else if (greebleZone2.CurrentlyVisible)
                     {
                         gzdata2._instancesState[m] = byte.MaxValue;
                     }
                 }
                 int maxInstancesModified2 = this._nonProxiedZones[l].MaxInstancesModified;
                 while (m < maxInstancesModified2)
                 {
                     gzdata2._instancesState[m] = 254;
                     m++;
                 }
             }
             else if (greebleZone2 && gzdata2 == null)
             {
                 gzdata2 = (this._greebleZonesData[i] = new GreebleZonesManager.GZData());
                 gzdata2._instancesState = new byte[greebleZone2.MaxInstancesModified];
                 for (int n = 0; n < gzdata2._instancesState.Length; n++)
                 {
                     gzdata2._instancesState[n] = 254;
                 }
             }
             i++;
         }
         this._savedVersion = this._proxy._currentVersion;
     }
 }