public static string GetTransportLogic(this ELogisticStorage eLogistic) { switch (eLogistic) { case ELogisticStorage.None: return("存"); case ELogisticStorage.Supply: return("出"); case ELogisticStorage.Demand: return("进"); default: return(""); } }
public StorageUI(int planetId, int stationId, int stationGId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic) { ItemCount = -1; //Indicate it is SetStationStorage() PlanetId = planetId; StationId = stationId; StationGId = stationGId; StorageIdx = storageIdx; ItemId = itemId; ItemCountMax = itemCountMax; LocalLogic = localLogic; RemoteLogic = remoteLogic; }
public StationUI(int planetId, int stationId, int stationGId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic) { IsStorageUI = true; ShouldMimic = false; PlanetId = planetId; StationId = stationId; StationGId = stationGId; StorageIdx = storageIdx; ItemId = itemId; ItemCountMax = itemCountMax; LocalLogic = localLogic; RemoteLogic = remoteLogic; }
public override void OnUpdate() { int num = 0; foreach (BlueprintBuilding blueprintBuilding in inspector.blueprint.buildings) { int protoId = blueprintBuilding.itemId; ItemProto proto = LDB.items.Select(protoId); if (!proto.prefabDesc.isStation || proto.prefabDesc.isCollectStation) { continue; } int[] parameters = blueprintBuilding.parameters; if (parameters != null && parameters.Length >= 2048) { for (int i = 0; i < proto.prefabDesc.stationMaxItemKinds; i++) { if (parameters[i * 6] > 0) { int itemId = parameters[i * 6]; ELogisticStorage localLogic = (ELogisticStorage)parameters[i * 6 + 1]; ELogisticStorage remoteLogic = (ELogisticStorage)parameters[i * 6 + 2]; StationData data = new StationData() { itemId = itemId, local = localLogic, remote = remoteLogic, slotId = i }; SetItem(num++, blueprintBuilding.index, proto.prefabDesc.isStellarStation, data); } } } } ClearComponentItems(num); }
public static bool SetStationStorage_Postfix(PlanetTransport __instance, int stationId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic, Player player) { if (SimulatedWorld.Initialized && !LocalPlayer.PatchLocks["PlanetTransport"]) { foreach (StationComponent stationComponent in GameMain.data.galacticTransport.stationPool) { if (stationComponent != null && stationComponent.planetId == GameMain.data.localPlanet.id && stationComponent.id == stationId) { StationUI packet = new StationUI(stationComponent.gid, __instance.planet.id, storageIdx, itemId, itemCountMax, localLogic, remoteLogic); LocalPlayer.SendPacket(packet); break; } } if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public StationUI(int stationGId, int planetId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic) { this.isStorageUI = true; this.stationGId = stationGId; this.planetId = planetId; // we could ommit this and instead search the galaxy when received but that would take some time this.storageIdx = storageIdx; this.itemId = itemId; this.itemCountMax = itemCountMax; this.localLogic = localLogic; this.remoteLogic = remoteLogic; this.shouldMimick = false; }
public StationUI(int stationGId, int planetId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic, bool isStellar) { this.isStorageUI = true; this.stationGId = stationGId; this.planetId = planetId; this.storageIdx = storageIdx; this.itemId = itemId; this.itemCountMax = itemCountMax; this.localLogic = localLogic; this.remoteLogic = remoteLogic; this.shouldMimick = false; this.isStellar = isStellar; }
public static bool SetStationStorage_Prefix(PlanetTransport __instance, int stationId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic) { if (Multiplayer.IsActive && !Multiplayer.Session.Ships.PatchLockILS) { StationComponent stationComponent = __instance.stationPool[stationId]; if (stationComponent != null) { StorageUI packet = new StorageUI(__instance.planet.id, stationComponent.id, stationComponent.gid, storageIdx, itemId, itemCountMax, localLogic, remoteLogic); Multiplayer.Session.Network.SendPacket(packet); } if (Multiplayer.Session.LocalPlayer.IsHost) { return(true); } return(false); } return(true); }
public static bool SetStationStorage_Postfix(PlanetTransport __instance, int stationId, int storageIdx, int itemId, int itemCountMax, ELogisticStorage localLogic, ELogisticStorage remoteLogic, Player player) { if (SimulatedWorld.Initialized && !ILSShipManager.PatchLockILS) { StationComponent stationComponent = __instance.stationPool[stationId]; if (stationComponent != null) { int id = ((stationComponent.isStellar == true) ? stationComponent.gid : stationComponent.id); StationUI packet = new StationUI(id, __instance.planet.id, storageIdx, itemId, itemCountMax, localLogic, remoteLogic, stationComponent.isStellar); LocalPlayer.SendPacket(packet); } if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static void PlanetTransport_GameTick_Postfix(PlanetTransport __instance) { if (ModDisabled == true) { return; } ELogisticStorage defaultLocalMode = Config.General.WarperLocalMode.Value; ELogisticStorage defaultRemoteMode = Config.General.WarperRemoteMode.Value; bool warpersRequiredToggleAutomation = Config.General.WarpersRequiredToggleAutomation.Value; bool showWarperSlot = Config.General.ShowWarperSlot.Value; int defaultMaxValue = Config.General.WarperMaxValue.Value; int warperId = ItemProto.kWarperId; PrefabDesc prefabDesc = LDB.items.Select(_ilsId).prefabDesc; int warperSlotIndex = prefabDesc.stationMaxItemKinds; for (int j = 1; j < __instance.stationCursor; j++) { if (__instance.stationPool[j] != null && __instance.stationPool[j].id == j) { StationComponent stationComponent = __instance.stationPool[j]; if (stationComponent.isCollector == true || stationComponent.isStellar == false) { continue; } bool needRefreshTraffic = false; if (stationComponent.storage.Length < prefabDesc.stationMaxItemKinds + 1) { List <StationStore> storeCopy = new List <StationStore>(stationComponent.storage); storeCopy.Add(new StationStore()); stationComponent.storage = storeCopy.ToArray(); __instance.SetStationStorage( stationComponent.id, warperSlotIndex, warperId, defaultMaxValue, defaultLocalMode, defaultRemoteMode, GameMain.mainPlayer); } if (showWarperSlot == true && stationComponent.storage[warperSlotIndex].itemId != warperId) { __instance.SetStationStorage( stationComponent.id, warperSlotIndex, warperId, defaultMaxValue, defaultLocalMode, defaultRemoteMode, GameMain.mainPlayer); } if (warpersRequiredToggleAutomation == true) { if (stationComponent.warperNecessary == true && stationComponent.storage[warperSlotIndex].localLogic != defaultLocalMode) { __instance.SetStationStorage( stationComponent.id, warperSlotIndex, warperId, defaultMaxValue, defaultLocalMode, stationComponent.storage[warperSlotIndex].remoteLogic, GameMain.mainPlayer); } else if (stationComponent.warperNecessary == false && stationComponent.storage[warperSlotIndex].localLogic != ELogisticStorage.Supply) { __instance.SetStationStorage( stationComponent.id, warperSlotIndex, warperId, defaultMaxValue, ELogisticStorage.Supply, stationComponent.storage[warperSlotIndex].remoteLogic, GameMain.mainPlayer); } } int manualWarperStoreIndex = Array.FindIndex(stationComponent.storage, store => store.itemId == warperId); if (manualWarperStoreIndex != -1 && manualWarperStoreIndex != warperSlotIndex && stationComponent.storage[warperSlotIndex].count <stationComponent.storage[warperSlotIndex].max && stationComponent.storage[manualWarperStoreIndex].count> stationComponent.storage[manualWarperStoreIndex].max) { int warperOverflowInManualSlot = stationComponent.storage[manualWarperStoreIndex].count - stationComponent.storage[manualWarperStoreIndex].max; int warperNeedInAutomaticSlot = stationComponent.storage[warperSlotIndex].max - stationComponent.storage[warperSlotIndex].count; int transferAmount = Mathf.Min(warperNeedInAutomaticSlot, warperOverflowInManualSlot); stationComponent.storage[manualWarperStoreIndex].count -= transferAmount; stationComponent.storage[warperSlotIndex].count += transferAmount; stationComponent.storage[warperSlotIndex].localOrder = 0; stationComponent.storage[warperSlotIndex].remoteOrder = 0; needRefreshTraffic = true; } if (manualWarperStoreIndex != -1 && (stationComponent.storage[warperSlotIndex].count == stationComponent.storage[warperSlotIndex].max && stationComponent.storage[warperSlotIndex].localLogic == ELogisticStorage.Demand && stationComponent.storage[warperSlotIndex].totalOrdered != 0 || stationComponent.storage[warperSlotIndex].count == 0 && stationComponent.storage[warperSlotIndex].localLogic == ELogisticStorage.Supply && stationComponent.storage[warperSlotIndex].totalOrdered != 0)) { int storageCount = stationComponent.storage[warperSlotIndex].count; stationComponent.storage[warperSlotIndex].count = 0; __instance.SetStationStorage( stationComponent.id, warperSlotIndex, 0, defaultMaxValue, defaultLocalMode, defaultRemoteMode, GameMain.mainPlayer); __instance.SetStationStorage( stationComponent.id, warperSlotIndex, warperId, defaultMaxValue, defaultLocalMode, defaultRemoteMode, GameMain.mainPlayer); stationComponent.storage[warperSlotIndex].count = storageCount; needRefreshTraffic = true; } if (needRefreshTraffic) { stationComponent.UpdateNeeds(); __instance.RefreshTraffic(); __instance.gameData.galacticTransport.RefreshTraffic(stationComponent.gid); } } } }