public override void OnCreated(IThreading threading)
 {
     BuildingWatcher.instance = this;
     this._initialized        = false;
     this._delta    = 0.0f;
     this._depotMap = new Dictionary <ItemClass.SubService, HashSet <ushort> >();
     base.OnCreated(threading);
 }
 public static bool IsLineDepotStillValid(ushort lineID, ref ushort depotID)
 {
     ItemClass.SubService subService;
     if ((int)depotID == 0 || !BuildingWatcher.IsValidDepot(ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)depotID], out subService))
     {
         depotID = TransportLineMod.GetClosestDepot(lineID, Singleton <NetManager> .instance.m_nodes.m_buffer[(int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].GetStop(0)].m_position);
         TransportLineMod._lineData[(int)lineID].Depot = depotID;
         if ((int)depotID == 0)
         {
             TransportLineMod.ClearEnqueuedVehicles(lineID);
             return(false);
         }
     }
     return(true);
 }
 public override void OnBeforeSimulationTick()
 {
     if (!this._initialized || !this._buildingManager.m_buildingsUpdated)
     {
         return;
     }
     for (int index1 = 0; index1 < this._buildingManager.m_updatedBuildings.Length; ++index1)
     {
         ulong updatedBuilding = this._buildingManager.m_updatedBuildings[index1];
         if ((long)updatedBuilding != 0L)
         {
             for (int index2 = 0; index2 < 64; ++index2)
             {
                 if (((long)updatedBuilding & 1L << index2) != 0L)
                 {
                     ushort num1 = (ushort)(index1 << 6 | index2);
                     ItemClass.SubService subService;
                     if (BuildingWatcher.IsValidDepot(ref this._buildingManager.m_buildings.m_buffer[(int)num1], out subService))
                     {
                         HashSet <ushort> ushortSet;
                         if (this._depotMap.TryGetValue(subService, out ushortSet))
                         {
                             ushortSet.Add(num1);
                         }
                         else
                         {
                             ushortSet = new HashSet <ushort>();
                             ushortSet.Add(num1);
                             this._depotMap.Add(subService, ushortSet);
                         }
                         // ISSUE: reference to a compiler-generated field
                         BuildingWatcher.DepotAdded onDepotAdded = this.OnDepotAdded;
                         if (onDepotAdded != null)
                         {
                             int num2 = (int)subService;
                             onDepotAdded((ItemClass.SubService)num2);
                         }
                     }
                 }
             }
         }
     }
     base.OnBeforeSimulationTick();
 }
 public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
 {
     if (!this._initialized)
     {
         return;
     }
     if ((double)this._delta > 1.0)
     {
         this._delta = 0.0f;
         HashSet <ushort> ushortSet1 = new HashSet <ushort>();
         foreach (KeyValuePair <ItemClass.SubService, HashSet <ushort> > depot in this._depotMap)
         {
             foreach (ushort num in depot.Value)
             {
                 ItemClass.SubService subService;
                 if (!BuildingWatcher.IsValidDepot(ref this._buildingManager.m_buildings.m_buffer[(int)num], out subService))
                 {
                     ushortSet1.Add(num);
                 }
             }
             if (ushortSet1.Count != 0)
             {
                 HashSet <ushort> ushortSet2;
                 if (this._depotMap.TryGetValue(depot.Key, out ushortSet2))
                 {
                     ushortSet2.ExceptWith((IEnumerable <ushort>)ushortSet1);
                     // ISSUE: reference to a compiler-generated field
                     BuildingWatcher.DepotRemoved onDepotRemoved = this.OnDepotRemoved;
                     if (onDepotRemoved != null)
                     {
                         int key = (int)depot.Key;
                         onDepotRemoved((ItemClass.SubService)key);
                     }
                 }
                 ushortSet1.Clear();
             }
         }
     }
     this._delta = this._delta + realTimeDelta;
     base.OnUpdate(realTimeDelta, simulationTimeDelta);
 }
 public void Init()
 {
     this._buildingManager = Singleton <BuildingManager> .instance;
     for (int index = 0; index < this._buildingManager.m_buildings.m_buffer.Length; ++index)
     {
         ItemClass.SubService subService;
         if (BuildingWatcher.IsValidDepot(ref this._buildingManager.m_buildings.m_buffer[index], out subService))
         {
             HashSet <ushort> ushortSet;
             if (this._depotMap.TryGetValue(subService, out ushortSet))
             {
                 ushortSet.Add((ushort)index);
             }
             else
             {
                 ushortSet = new HashSet <ushort>();
                 ushortSet.Add((ushort)index);
                 this._depotMap.Add(subService, ushortSet);
             }
         }
     }
     this._initialized = true;
 }
 public override void OnReleased()
 {
     BuildingWatcher.instance = (BuildingWatcher)null;
     base.OnReleased();
 }