/* * This is triggered by server and either adds or removes items to an ILS caused by a ship transport. * Also update the remoteOrder value to reflect the changes */ public static void AddTakeItem(ILSShipItems packet) { if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient || GameMain.data.galacticTransport.stationPool.Length <= packet.stationGID) { return; } StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.stationGID]; if (stationComponent != null && stationComponent.gid == packet.stationGID && stationComponent.storage != null) { if (packet.addItem) { stationComponent.AddItem(packet.itemId, packet.itemCount); for (int i = 0; i < stationComponent.storage.Length; i++) { if (stationComponent.storage[i].itemId == packet.itemId) { stationComponent.storage[i].remoteOrder -= packet.itemCount; RefreshValuesUI(stationComponent, i); break; } } } else { int itemId = packet.itemId; int itemCount = packet.itemCount; stationComponent.TakeItem(ref itemId, ref itemCount); // TODO: Update remote order here (issue #230) } } }
public static void AddTakeItem(ILSShipItems packet) { if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient) { return; } foreach (StationComponent stationComponent in GameMain.data.galacticTransport.stationPool) { if (stationComponent != null && stationComponent.gid == packet.stationGID) { PlanetData pData = GameMain.galaxy.PlanetById(stationComponent.planetId); if (pData?.factory?.transport != null) { foreach (StationComponent stationComponentPlanet in pData.factory.transport.stationPool) { if (stationComponentPlanet != null && stationComponentPlanet.gid == stationComponent.gid) { if (packet.AddItem) { //Log.Info($"Calling AddItem() with item {packet.itemId} and amount {packet.itemCount}"); stationComponentPlanet.AddItem(packet.itemId, packet.itemCount); } else { //Log.Info($"Calling TakeItem() with item {packet.itemId} and amount {packet.itemCount}"); int itemId = packet.itemId; int itemCount = packet.itemCount; stationComponentPlanet.TakeItem(ref itemId, ref itemCount); } break; } } } break; } } }