public void ProcessPacket(StationUIInitialSync packet, NebulaConnection conn) { StationComponent[] gStationPool = null; if (packet.planetId == 0) { gStationPool = GameMain.data.galacticTransport.stationPool; } else { PlanetData pData = GameMain.galaxy.PlanetById(packet.planetId); if (pData?.factory?.transport != null) { gStationPool = pData.factory.transport.stationPool; } } if (gStationPool != null && gStationPool.Length > packet.stationGId && StationUIManager.UIIsSyncedStage == 1) { StationComponent stationComponent = gStationPool[packet.stationGId]; if (stationComponent != null) { UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow; stationComponent.tripRangeDrones = packet.tripRangeDrones; stationComponent.tripRangeShips = packet.tripRangeShips; stationComponent.deliveryDrones = packet.deliveryDrones; stationComponent.deliveryShips = packet.deliveryShips; stationComponent.warpEnableDist = packet.warpEnableDist; stationComponent.warperNecessary = packet.warperNecessary; stationComponent.includeOrbitCollector = packet.includeOrbitCollector; stationComponent.energy = packet.energy; stationComponent.energyPerTick = packet.energyPerTick; for (int i = 0; i < packet.itemId.Length; i++) { if (stationComponent.storage == null) { // 3 is games default storage places for PLS stationComponent.storage = new StationStore[packet.itemId.Length]; } stationComponent.storage[i].itemId = packet.itemId[i]; stationComponent.storage[i].max = packet.itemCountMax[i]; stationComponent.storage[i].count = packet.itemCount[i]; stationComponent.storage[i].remoteOrder = packet.remoteOrder[i]; stationComponent.storage[i].localLogic = (ELogisticStorage)packet.localLogic[i]; stationComponent.storage[i].remoteLogic = (ELogisticStorage)packet.remoteLogic[i]; } if (stationWindow != null && stationWindow.active) { conn.SendPacket(new StationSubscribeUIUpdates(true, stationComponent.gid)); StationUIManager.UIIsSyncedStage++; stationWindow._Free(); stationWindow._Init(stationComponent); AccessTools.Field(typeof(UIStationWindow), "_stationId").SetValue(stationWindow, stationComponent.id); stationWindow._Open(); stationWindow._Update(); } StationUIManager.UIStationId = stationComponent.id; } } }
public override void ProcessPacket(StationUIInitialSync packet, NebulaConnection conn) { StationComponent stationComponent = null; StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool; StationComponent[] stationPool = GameMain.data.galaxy.PlanetById(packet.PlanetId).factory.transport.stationPool; stationComponent = packet.StationGId > 0 ? gStationPool[packet.StationGId] : stationPool?[packet.StationId]; if (stationComponent == null) { Log.Error($"StationUIInitialSyncProcessor: Unable to find requested station on planet {packet.PlanetId} with id {packet.StationId} and gid of {packet.StationGId}"); return; } if (StationUIManager.UIIsSyncedStage == 1) { UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow; stationComponent.tripRangeDrones = packet.TripRangeDrones; stationComponent.tripRangeShips = packet.TripRangeShips; stationComponent.deliveryDrones = packet.DeliveryDrones; stationComponent.deliveryShips = packet.DeliveryShips; stationComponent.warpEnableDist = packet.WarperEnableDistance; stationComponent.warperNecessary = packet.WarperNecessary; stationComponent.includeOrbitCollector = packet.IncludeOrbitCollector; stationComponent.energy = packet.Energy; stationComponent.energyPerTick = packet.EnergyPerTick; for (int i = 0; i < packet.ItemId.Length; i++) { if (stationComponent.storage == null) { stationComponent.storage = new StationStore[packet.ItemId.Length]; } stationComponent.storage[i].itemId = packet.ItemId[i]; stationComponent.storage[i].max = packet.ItemCountMax[i]; stationComponent.storage[i].count = packet.ItemCount[i]; stationComponent.storage[i].remoteOrder = packet.RemoteOrder[i]; stationComponent.storage[i].localLogic = (ELogisticStorage)packet.LocalLogic[i]; stationComponent.storage[i].remoteLogic = (ELogisticStorage)packet.RemoteLogic[i]; } if (stationWindow != null && stationWindow.active) { conn.SendPacket(new StationSubscribeUIUpdates(true, stationComponent.planetId, stationComponent.id, stationComponent.gid)); StationUIManager.UIIsSyncedStage++; stationWindow._Free(); stationWindow._Init(stationComponent); AccessTools.Field(typeof(UIStationWindow), "_stationId").SetValue(stationWindow, stationComponent.id); stationWindow._Open(); stationWindow._Update(); } StationUIManager.UIStationId = stationComponent.id; } }
public void ProcessPacket(StationUIInitialSync packet, NebulaConnection conn) { Debug.Log("received sync packet"); StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool; if (gStationPool.Length > packet.stationGId && StationUIManager.UIIsSyncedStage == 1) { StationComponent stationComponent = gStationPool[packet.stationGId]; if (stationComponent != null) { UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow; if (stationWindow != null && stationWindow.active) { // here it was } stationComponent.tripRangeDrones = packet.tripRangeDrones; stationComponent.tripRangeShips = packet.tripRangeShips; stationComponent.deliveryDrones = packet.deliveryDrones; stationComponent.deliveryShips = packet.deliveryShips; stationComponent.warpEnableDist = packet.warpEnableDist; stationComponent.warperNecessary = packet.warperNecessary; stationComponent.includeOrbitCollector = packet.includeOrbitCollector; for (int i = 0; i < packet.itemId.Length; i++) { stationComponent.storage[i].itemId = packet.itemId[i]; stationComponent.storage[i].max = packet.itemCountMax[i]; switch (packet.localLogic[i]) { case 0: stationComponent.storage[i].localLogic = ELogisticStorage.None; break; case 1: stationComponent.storage[i].localLogic = ELogisticStorage.Supply; break; case 2: stationComponent.storage[i].localLogic = ELogisticStorage.Demand; break; } switch (packet.remoteLogic[i]) { case 0: stationComponent.storage[i].remoteLogic = ELogisticStorage.None; break; case 1: stationComponent.storage[i].remoteLogic = ELogisticStorage.Supply; break; case 2: stationComponent.storage[i].remoteLogic = ELogisticStorage.Demand; break; } } if (stationWindow != null && stationWindow.active) { conn.SendPacket(new StationSubscribeUIUpdates(true, stationComponent.gid)); StationUIManager.UIIsSyncedStage++; stationWindow._Free(); stationWindow._Init(stationComponent); AccessTools.Field(typeof(UIStationWindow), "_stationId").SetValue(stationWindow, stationComponent.id); stationWindow._Open(); stationWindow._Update(); } StationUIManager.UIStationId = stationComponent.id; } } }