private static void UpdateStorageUI(StationUI packet) { StationComponent stationComponent = null; PlanetData planet = GameMain.galaxy?.PlanetById(packet.PlanetId); // If we can't find planet or the factory for said planet, we can just skip this if (planet?.factory?.transport == null) { return; } StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool; StationComponent[] stationPool = planet?.factory?.transport?.stationPool; stationComponent = packet.StationGId > 0 ? gStationPool[packet.StationGId] : stationPool?[packet.StationId]; if (stationComponent == null) { Log.Error($"UpdateStorageUI: Unable to find requested station on planet {packet.PlanetId} with id {packet.StationId} and gid of {packet.StationGId}"); return; } using (ILSShipManager.PatchLockILS.On()) { planet.factory.transport.SetStationStorage(stationComponent.id, packet.StorageIdx, packet.ItemId, packet.ItemCountMax, packet.LocalLogic, packet.RemoteLogic, (packet.ShouldMimic == true) ? GameMain.mainPlayer : null); } }
public static bool OnItemIconMouseUp_Postfix(UIStationStorage __instance, BaseEventData evt) { if (SimulatedWorld.Initialized && !LocalPlayer.PatchLocks["UIStationStorage"]) { StationUIManager.lastMouseEvent = evt; StationUIManager.lastMouseEventWasDown = false; StationUI packet; if (LocalPlayer.IsMasterClient) { if ((bool)AccessTools.Field(typeof(UIStationStorage), "insplit").GetValue(__instance)) { int splitVal = UIRoot.instance.uiGame.gridSplit.value; int diff = (splitVal >= __instance.station.storage[__instance.index].count) ? __instance.station.storage[__instance.index].count : splitVal; packet = new StationUI(__instance.station.gid, __instance.stationWindow.factory.planet.id, __instance.index, 12, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count - diff); LocalPlayer.SendPacket(packet); } } else { packet = new StationUI(__instance.station.gid, __instance.stationWindow.factory.planet.id, __instance.index, 11, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count); LocalPlayer.SendPacket(packet); } if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static bool OnItemIconMouseUp_Postfix(UIStationStorage __instance, BaseEventData evt) { if (SimulatedWorld.Initialized && !ILSShipManager.PatchLockILS) { StationUIManager.lastMouseEvent = evt; StationUIManager.lastMouseEventWasDown = false; StationUI packet; if (LocalPlayer.IsMasterClient) { if ((bool)AccessTools.Field(typeof(UIStationStorage), "insplit").GetValue(__instance)) { int splitVal = UIRoot.instance.uiGame.gridSplit.value; int diff = (splitVal >= __instance.station.storage[__instance.index].count) ? __instance.station.storage[__instance.index].count : splitVal; int id = ((__instance.station.isStellar == true) ? __instance.station.gid : __instance.station.id); packet = new StationUI(id, __instance.stationWindow.factory.planet.id, __instance.index, StationUI.UIsettings.addOrRemoveItemFromStorageResp, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count - diff, __instance.station.isStellar); LocalPlayer.SendPacket(packet); } } else { int id = ((__instance.station.isStellar == true) ? __instance.station.gid : __instance.station.id); packet = new StationUI(id, __instance.stationWindow.factory.planet.id, __instance.index, StationUI.UIsettings.addOrRemoveItemFromStorageReq, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count, __instance.station.isStellar); LocalPlayer.SendPacket(packet); } if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static bool OnItemIconMouseDown_Postfix(UIStationStorage __instance, BaseEventData evt) { if (SimulatedWorld.Initialized && !LocalPlayer.PatchLocks["UIStationStorage"]) { StationUIManager.lastMouseEvent = evt; StationUIManager.lastMouseEventWasDown = true; StationUI packet; if (LocalPlayer.IsMasterClient) { PointerEventData pointEventData = evt as PointerEventData; if (GameMain.mainPlayer.inhandItemId == __instance.station.storage[__instance.index].itemId && pointEventData.button == PointerEventData.InputButton.Left) { int diff = __instance.station.storage[__instance.index].max - __instance.station.storage[__instance.index].count; int amount = (diff >= GameMain.mainPlayer.inhandItemCount) ? GameMain.mainPlayer.inhandItemCount : diff; if (amount < 0) { amount = 0; } packet = new StationUI(__instance.station.gid, __instance.stationWindow.factory.planet.id, __instance.index, 12, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count + amount); LocalPlayer.SendPacket(packet); } } else { packet = new StationUI(__instance.station.gid, __instance.stationWindow.factory.planet.id, __instance.index, 11, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count); LocalPlayer.SendPacket(packet); } if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static void UpdateUI(StationUI packet) { if ((UpdateCooldown == 0 || !packet.isStorageUI) && LocalPlayer.IsMasterClient) { UpdateCooldown = 10; if (packet.isStorageUI) { UpdateStorageUI(packet); } else { UpdateSettingsUI(packet); } } else if (!LocalPlayer.IsMasterClient) { if (packet.isStorageUI) { UpdateStorageUI(packet); } else { UpdateSettingsUI(packet); } } }
public static void UpdateUI(StationUI packet) { Debug.Log("handling packet " + packet.settingIndex); if ((UpdateCooldown == 0 || !packet.isStorageUI) && LocalPlayer.IsMasterClient) { UpdateCooldown = 10; if (packet.isStorageUI) { UpdateStorageUI(packet); } else { UpdateSettingsUI(packet); } } else if (!LocalPlayer.IsMasterClient) { if (packet.isStorageUI) { UpdateStorageUI(packet); } else { UpdateSettingsUI(packet); } } }
public static void LoadProfile() { //загрузка данных профиля Profile profile = ContextManagerGamePro.Instance().Profile; JsonData data = DataLoad(profile); profile.Day = (int)data["Day"]; profile.credits = (int)data["ProfileStats"][0]; profile.fame = (int)data["ProfileStats"][1]; if (ContextManagerGamePro.Instance().Profile.isTutorialPart1 == true) { profile.isTutorialPart1 = (bool)data["isTutorialPart1"]; } profile.isTutorialPart2 = (bool)data["isTutorialPart2"]; profile.isTutorialPart3 = (bool)data["isTutorialPart3"]; StationUI UI = GameObject.Find("StationUI").GetComponent <StationUI>(); Transform stationinventory = UI.stationinventory.transform.GetChild(0).transform.GetChild(0); for (int i = 0; i < data["Items"].Count; i++) { GameObject item = Instantiate(Resources.Load("items/" + data["Items"][i]["itemID"].ToString()) as GameObject); item.GetComponent <Item>().stackvalue = (int)data["Items"][i]["value"]; item.transform.SetParent(stationinventory); item.transform.localScale = Vector3.one; } }
public static bool OnIncludeOrbitCollectorClick_Prefix(UIStationWindow __instance) { if (__instance.event_lock || !Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) { return(true); } StationUI packet = new StationUI(__instance.factory.planet.id, __instance.factory.transport.stationPool[__instance.stationId].id, __instance.factory.transport.stationPool[__instance.stationId].gid, StationUI.EUISettings.IncludeCollectors, 0f); Multiplayer.Session.Network.SendPacket(packet); return(Multiplayer.Session.LocalPlayer.IsHost); }
private static void UpdateStorageUI(StationUI packet) { PlanetData pData = GameMain.galaxy.PlanetById(packet.planetId); if (pData == null) { // this should never happen return; } if (pData.factory == null && !LocalPlayer.IsMasterClient) { // in this case client will receive the settings once he arrives at the planet and receives the PlanetFactory } else { /* * we need to find the stations id in the PlanetTransport structure to call SetStationStorage */ int id = -1; if (pData.factory?.transport == null) { return; } if ((!packet.isStellar && packet.stationGId >= pData.factory.transport.stationPool.Length) || pData.factory.transport == null) { return; } else if (packet.isStellar) { foreach (StationComponent stationComponent in pData.factory.transport.stationPool) { if (stationComponent != null && stationComponent.gid == packet.stationGId) { id = stationComponent.id; } } } else { // if its a PLS server sends the id and not GId id = pData.factory.transport.stationPool[packet.stationGId].id; } if (id == -1) { return; } using (ILSShipManager.PatchLockILS.On()) { pData.factory.transport.SetStationStorage(id, packet.storageIdx, packet.itemId, packet.itemCountMax, packet.localLogic, packet.remoteLogic, null); } } }
public static void OnPilerCountChange(UIStationWindow __instance) { if (__instance.event_lock || !Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) { return; } StationComponent stationComponent = __instance.transport.stationPool[__instance.stationId]; StationUI packet = new StationUI(__instance.factory.planet.id, stationComponent.id, stationComponent.gid, StationUI.EUISettings.PilerCount, stationComponent.pilerCount); Multiplayer.Session.Network.SendPacket(packet); }
void Load() { ContextManagerGamePro.Instance().StaticMetods.LoadProfileData(); StationUI ui = GameObject.Find("StationUI").GetComponent <StationUI>(); if (ui.PlayerActualShip.transform.childCount > 0) { return; } ContextManagerGamePro.Instance().StaticMetods.LoadShipData(); }
public static bool OnIncludeOrbitCollectorClick_Prefix(UIStationWindow __instance, int obj) { if (SimulatedWorld.Initialized && !ILSShipManager.PatchLockILS && (StationUIManager.UIIsSyncedStage == 2 || LocalPlayer.IsMasterClient)) { StationUI packet = new StationUI(__instance.factory.transport.stationPool[__instance.stationId].gid, __instance.factory.planet.id, StationUI.UIsettings.includeCollectors, 0f); LocalPlayer.SendPacket(packet); if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static bool OnMaxChargePowerSliderValueChange_Prefix(UIStationWindow __instance, float value) { if (SimulatedWorld.Initialized && !ILSShipManager.PatchLockILS) { StationUI packet = new StationUI(__instance.factory.transport.stationPool[__instance.stationId].gid, __instance.factory.planet.id, StationUI.UIsettings.MaxChargePower, value); LocalPlayer.SendPacket(packet); if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static bool OnWarperDistanceValueChange_Prefix(UIStationWindow __instance, float value) { if (SimulatedWorld.Initialized && !ILSShipManager.PatchLockILS && (StationUIManager.UIIsSyncedStage == 2 || LocalPlayer.IsMasterClient)) { StationUI packet = new StationUI(__instance.factory.transport.stationPool[__instance.stationId].gid, __instance.factory.planet.id, StationUI.UIsettings.WarpDistance, value); LocalPlayer.SendPacket(packet); if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static bool OnMinDeliverVesselValueChange_Prefix(UIStationWindow __instance, float value) { if (SimulatedWorld.Initialized && !LocalPlayer.PatchLocks["UIStationWindow"] && (StationUIManager.UIIsSyncedStage == 2 || LocalPlayer.IsMasterClient)) { StationUI packet = new StationUI(__instance.factory.transport.stationPool[__instance.stationId].gid, __instance.factory.planet.id, 4, value); LocalPlayer.SendPacket(packet); if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static bool OnWarperNecessaryClick_Prefix(UIStationWindow __instance, int obj) { if (SimulatedWorld.Initialized && !LocalPlayer.PatchLocks["UIStationWindow"] && (StationUIManager.UIIsSyncedStage == 2 || LocalPlayer.IsMasterClient)) { StationUI packet = new StationUI(__instance.factory.transport.stationPool[__instance.stationId].gid, __instance.factory.planet.id, 6, 0f); LocalPlayer.SendPacket(packet); if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
private void Awake() { //Check if instance already exists if (Instance == null) { //if not, set instance to this Instance = this; } //If instance already exists and it's not this: else if (Instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } }
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 bool OnShipIconClick_Prefix(UIStationWindow __instance, int obj) { if (SimulatedWorld.Initialized && !ILSShipManager.PatchLockILS) { Player player = GameMain.mainPlayer; if (player.inhandItemCount > 0 && player.inhandItemId != 5002) { ItemProto itemProto = LDB.items.Select(5002); UIRealtimeTip.Popup("只能放入".Translate() + itemProto.name, true, 0); return(false); } StationComponent stationComponent = __instance.transport.stationPool[__instance.stationId]; int toAdd; if (player.inhandItemCount > 0) { int shipAmount = stationComponent.idleShipCount + stationComponent.workShipCount; int spaceLeft = 10 - shipAmount; if (spaceLeft < 0) { spaceLeft = 0; } toAdd = (__instance.player.inhandItemCount >= spaceLeft) ? spaceLeft : __instance.player.inhandItemCount; } else { toAdd = stationComponent.idleShipCount * -1; } if (!LocalPlayer.IsMasterClient) { StationUIManager.UIRequestedShipDronWarpChange = true; } StationUI packet = new StationUI(stationComponent.gid, __instance.factory.planet.id, StationUI.UIsettings.setShipCount, stationComponent.idleShipCount + toAdd); LocalPlayer.SendPacket(packet); if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static void CreateShipFromFile() { JsonData data = DataLoad(ContextManagerGamePro.Instance().Profile); //загрузка текущего корабля if (data["PlayerShip"]["ShipId"].ToString() != "emptyID") { GameObject ship = Instantiate(Resources.Load(data["PlayerShip"]["ShipId"].ToString()) as GameObject); ship.name = data["PlayerShip"]["ShipId"].ToString(); Ship shipscript = ship.GetComponent <Ship>(); ContextManagerGamePro.Instance().playership = shipscript; List <ComponentSlot> Slots = new List <ComponentSlot>(); List <ItemInSlot> itemsIds = new List <ItemInSlot>(); Slots.AddRange(ship.GetComponentsInChildren <ComponentSlot>()); for (int i = 0; i < data["PlayerShip"]["Items"].Count; i++) { itemsIds.Add(new ItemInSlot("items/" + data["PlayerShip"]["Items"][i]["Id"].ToString(), (int)data["PlayerShip"]["Items"][i]["slotnumber"])); } foreach (ComponentSlot slot in Slots) { foreach (ItemInSlot item in itemsIds) { if (slot.slotnumber == item.slotnumber) { slot.ship = shipscript; GameObject _item = Instantiate(Resources.Load(item.Id) as GameObject); _item.transform.SetParent(slot.transform); _item.transform.SetSiblingIndex(0); _item.GetComponent <Item>().EqipItem(slot); } } } StationUI UI = GameObject.Find("StationUI").GetComponent <StationUI>(); UI.ship = shipscript; ship.transform.SetParent(UI.PlayerActualShip.transform); } }
public static void OnWarperIconClick_Posfix(UIStationWindow __instance, int __state) { if (__instance.event_lock || !Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS) { return; } StationComponent stationComponent = __instance.transport.stationPool[__instance.stationId]; if (__state != stationComponent.warperCount) { StationUI packet = new StationUI(__instance.factory.planet.id, stationComponent.id, stationComponent.gid, StationUI.EUISettings.SetWarperCount, stationComponent.warperCount); Multiplayer.Session.Network.SendPacket(packet); if (Multiplayer.Session.LocalPlayer.IsClient) { // Revert warper count until host verify stationComponent.warperCount = __state; __instance.warperIconButton.button.interactable = false; } } }
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); }
private static void UpdateStorageUI(StationUI packet) { PlanetData pData = GameMain.galaxy.PlanetById(packet.planetId); if (pData == null) { // this should never happen return; } if (pData.factory == null && !LocalPlayer.IsMasterClient) { // in this case client will receive the settings once he arrives at the planet and receives the PlanetFactory } else { if (pData.factory?.transport == null) { return; } int stationId = -1; for (int i = 0; i < pData.factory.transport.stationPool.Length; i++) { if (pData.factory.transport.stationPool[i] != null && pData.factory.transport.stationPool[i].gid == packet.stationGId) { stationId = pData.factory.transport.stationPool[i].id; break; } } if (stationId == -1) { return; } LocalPlayer.PatchLocks["PlanetTransport"] = true; pData.factory.transport.SetStationStorage(stationId, packet.storageIdx, packet.itemId, packet.itemCountMax, packet.localLogic, packet.remoteLogic, null); LocalPlayer.PatchLocks["PlanetTransport"] = false; } }
public static bool OnItemIconMouseDown_Postfix(UIStationStorage __instance, BaseEventData evt) { if (SimulatedWorld.Initialized && !ILSShipManager.PatchLockILS) { StationUIManager.lastMouseEvent = evt; StationUIManager.lastMouseEventWasDown = true; StationUI packet; if (LocalPlayer.IsMasterClient) { PointerEventData pointEventData = evt as PointerEventData; if (GameMain.mainPlayer.inhandItemId == __instance.station.storage[__instance.index].itemId && pointEventData.button == PointerEventData.InputButton.Left) { int diff = __instance.station.storage[__instance.index].max - __instance.station.storage[__instance.index].count; int amount = (diff >= GameMain.mainPlayer.inhandItemCount) ? GameMain.mainPlayer.inhandItemCount : diff; if (amount < 0) { amount = 0; } int id = ((__instance.station.isStellar == true) ? __instance.station.gid : __instance.station.id); packet = new StationUI(id, __instance.stationWindow.factory.planet.id, __instance.index, StationUI.UIsettings.addOrRemoveItemFromStorageResp, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count + amount, __instance.station.isStellar); LocalPlayer.SendPacket(packet); } } else { int id = ((__instance.station.isStellar == true) ? __instance.station.gid : __instance.station.id); packet = new StationUI(id, __instance.stationWindow.factory.planet.id, __instance.index, StationUI.UIsettings.addOrRemoveItemFromStorageReq, __instance.station.storage[__instance.index].itemId, __instance.station.storage[__instance.index].count, __instance.station.isStellar); LocalPlayer.SendPacket(packet); } if (LocalPlayer.IsMasterClient) { return(true); } return(false); } return(true); }
public static void EntityFastTakeOut_Postfix(PlanetFactory __instance, int entityId) { // belt, splitter, monitor, piler: handle by BeltFastTakeOut // storage: sync in StorageComponent.TakeItemFromGrid // powerNode, powerCon, powerAcc: no fill in interaction if (Multiplayer.IsActive && entityId > 0 && __instance.entityPool[entityId].id == entityId) { EntityData entityData = __instance.entityPool[entityId]; if (entityData.assemblerId > 0) { int assemblerId = entityData.assemblerId; AssemblerComponent[] assemblerPool = __instance.factorySystem.assemblerPool; if (assemblerPool[assemblerId].recipeId > 0) { int[] produced = assemblerPool[assemblerId].produced; for (int j = 0; j < produced.Length; j++) { Multiplayer.Session.Network.SendPacketToLocalStar(new AssemblerUpdateProducesPacket(j, produced[j], __instance.planetId, assemblerId)); } } } if (entityData.ejectorId > 0) { int ejectorId = entityData.ejectorId; EjectorComponent[] ejectorPool = __instance.factorySystem.ejectorPool; Multiplayer.Session.Network.SendPacketToLocalStar(new EjectorStorageUpdatePacket(ejectorId, ejectorPool[ejectorId].bulletCount, ejectorPool[ejectorId].bulletInc, __instance.planetId)); } if (entityData.inserterId > 0) { int inserterId = entityData.inserterId; InserterComponent[] inserterPool = __instance.factorySystem.inserterPool; Multiplayer.Session.Network.SendPacketToLocalStar(new InserterItemUpdatePacket(in inserterPool[inserterId], __instance.planetId)); } if (entityData.fractionatorId > 0) { int fractionatorId = entityData.fractionatorId; FractionatorComponent[] fractionatorPool = __instance.factorySystem.fractionatorPool; Multiplayer.Session.Network.SendPacketToLocalStar(new FractionatorStorageUpdatePacket(in fractionatorPool[fractionatorId], __instance.planetId)); } if (entityData.labId > 0) { int labId = entityData.labId; LabComponent[] labPool = __instance.factorySystem.labPool; if (labPool[labId].matrixMode) { Multiplayer.Session.Network.SendPacketToLocalStar(new LaboratoryUpdateEventPacket(-3, labId, __instance.planetId)); } } if (entityData.minerId > 0) { int minerId = entityData.minerId; MinerComponent[] minerPool = __instance.factorySystem.minerPool; Multiplayer.Session.Network.SendPacketToLocalStar(new MinerStoragePickupPacket(minerId, __instance.planetId)); } if (entityData.powerExcId > 0) { int powerExcId = entityData.powerExcId; PowerExchangerComponent[] excPool = __instance.powerSystem.excPool; Multiplayer.Session.Network.SendPacketToLocalStar(new PowerExchangerStorageUpdatePacket(powerExcId, excPool[powerExcId].emptyCount, excPool[powerExcId].fullCount, __instance.planetId)); } if (entityData.powerGenId > 0) { int powerGenId = entityData.powerGenId; PowerGeneratorComponent[] genPool = __instance.powerSystem.genPool; Multiplayer.Session.Network.SendPacketToLocalStar(new PowerGeneratorFuelUpdatePacket(powerGenId, genPool[powerGenId].fuelId, genPool[powerGenId].fuelCount, genPool[powerGenId].fuelInc, __instance.planetId)); if (genPool[powerGenId].productId > 0) { Multiplayer.Session.Network.SendPacketToLocalStar(new PowerGeneratorProductUpdatePacket(in genPool[powerGenId], __instance.planetId)); } } if (entityData.stationId > 0) { int stationId = entityData.stationId; StationComponent stationComponent = __instance.transport.stationPool[stationId]; for (int i = 0; i < stationComponent.storage.Length; i++) { if (stationComponent.storage[i].itemId > 0) { StorageUI packet = new StorageUI(__instance.planetId, stationComponent.id, stationComponent.gid, i, stationComponent.storage[i].count, stationComponent.storage[i].inc); Multiplayer.Session.Network.SendPacket(packet); } } if (!stationComponent.isCollector && !stationComponent.isVeinCollector) { StationUI packet = new StationUI(__instance.planetId, stationComponent.id, stationComponent.gid, StationUI.EUISettings.SetDroneCount, stationComponent.idleDroneCount + stationComponent.workDroneCount); Multiplayer.Session.Network.SendPacket(packet); } if (stationComponent.isStellar && !stationComponent.isCollector && !stationComponent.isVeinCollector) { StationUI packet = new StationUI(__instance.planetId, stationComponent.id, stationComponent.gid, StationUI.EUISettings.SetShipCount, stationComponent.idleShipCount + stationComponent.workShipCount); Multiplayer.Session.Network.SendPacket(packet); } if (stationComponent.isStellar && !stationComponent.isCollector && !stationComponent.isVeinCollector && __instance.gameData.history.logisticShipWarpDrive) { StationUI packet = new StationUI(__instance.planetId, stationComponent.id, stationComponent.gid, StationUI.EUISettings.SetWarperCount, stationComponent.warperCount); Multiplayer.Session.Network.SendPacket(packet); } } if (entityData.siloId > 0) { int siloId = entityData.siloId; SiloComponent[] siloPool = __instance.factorySystem.siloPool; Multiplayer.Session.Network.SendPacketToLocalStar(new SiloStorageUpdatePacket(siloId, siloPool[siloId].bulletCount, siloPool[siloId].bulletInc, __instance.planetId)); } if (entityData.tankId > 0) { int tankId = entityData.tankId; TankComponent[] tankPool = __instance.factoryStorage.tankPool; Multiplayer.Session.Network.SendPacketToLocalStar(new TankStorageUpdatePacket(in tankPool[tankId], __instance.planetId)); } } }
/* * if the local player does not have the corresponding station window opened we still need to update some (or all for host) settings * so do that here */ private static void UpdateSettingsUIBackground(StationUI packet, PlanetData pData, int stationGId) { StationComponent[] stationPool = GameMain.data.galacticTransport.stationPool; int stationId = stationGId; // if we have the planet factory loaded take the local transport array, if not take the global galactic array if (pData?.factory != null && pData?.factory?.transport != null) { stationPool = pData.factory.transport.stationPool; for (int i = 0; i < stationPool.Length; i++) { if (stationPool[i] != null && stationPool[i].gid == stationGId) { stationId = stationPool[i].id; break; } } } // update drones, ships, warpers and energy consumption for everyone if ((packet.settingIndex >= StationUI.UIsettings.setDroneCount && packet.settingIndex <= StationUI.UIsettings.setWarperCount) || packet.settingIndex == StationUI.UIsettings.MaxChargePower) { if (stationPool.Length > stationId) { if (packet.settingIndex == (int)StationUI.UIsettings.MaxChargePower && pData.factory?.powerSystem != null) { PowerConsumerComponent[] consumerPool = pData.factory.powerSystem.consumerPool; if (consumerPool.Length > stationPool[stationId].pcId) { consumerPool[stationPool[stationId].pcId].workEnergyPerTick = (long)(50000.0 * (double)packet.settingValue + 0.5); } } if (packet.settingIndex == StationUI.UIsettings.setDroneCount) { stationPool[stationId].idleDroneCount = (int)packet.settingValue; } if (packet.settingIndex == StationUI.UIsettings.setShipCount) { stationPool[stationId].idleShipCount = (int)packet.settingValue; } if (packet.settingIndex == StationUI.UIsettings.setWarperCount) { stationPool[stationId].warperCount = (int)packet.settingValue; } } } // only host should update everything if (!LocalPlayer.IsMasterClient) { return; } if (packet.settingIndex == StationUI.UIsettings.MaxTripDrones) { if (stationPool.Length > stationId) { stationPool[stationId].tripRangeDrones = Math.Cos((double)packet.settingValue / 180.0 * 3.141592653589793); } } if (packet.settingIndex == StationUI.UIsettings.MaxTripVessel) { if (stationPool.Length > stationId) { double value = packet.settingValue; if (value > 40.5) { value = 10000.0; } else if (value > 20.5) { value = value * 2f - 20f; } stationPool[stationId].tripRangeShips = 2400000.0 * value; } } if (packet.settingIndex == StationUI.UIsettings.MinDeliverDrone) { if (stationPool.Length > stationId) { int value = (int)(packet.settingValue * 10f + 0.5f); if (value < 1) { value = 1; } stationPool[stationId].deliveryDrones = value; } } if (packet.settingIndex == StationUI.UIsettings.MinDeliverVessel) { if (stationPool.Length > stationId) { int value = (int)(packet.settingValue * 10f + 0.5f); if (value < 1) { value = 1; } stationPool[stationId].deliveryShips = value; } } if (packet.settingIndex == StationUI.UIsettings.WarpDistance) { if (stationPool.Length > stationId) { double value = packet.settingValue; if (value < 1.5) { value = 0.2; } else if (value < 7.5) { value = value * 0.5 - 0.5; } else if (value < 16.5) { value -= 4f; } else if (value < 20.5) { value = value * 2f - 20f; } else { value = 60; } stationPool[stationId].warpEnableDist = 40000.0 * value; } } if (packet.settingIndex == StationUI.UIsettings.warperNeeded) { if (stationPool.Length > stationId) { stationPool[stationId].warperNecessary = !stationPool[stationId].warperNecessary; } } if (packet.settingIndex == StationUI.UIsettings.includeCollectors) { if (stationPool.Length > stationId) { stationPool[stationId].includeOrbitCollector = !stationPool[stationId].includeOrbitCollector; } } if (packet.settingIndex == StationUI.UIsettings.addOrRemoveItemFromStorageResp) { if (stationPool[stationId].storage != null) { stationPool[stationId].storage[packet.storageIdx].count = (int)packet.settingValue; } } }
/* * update settings and item, drone, ship and warper count * first determine if the local player has the station window opened and hadle that accordingly. */ private static void UpdateSettingsUI(StationUI packet) { UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow; if (stationWindow != null) { int _stationId = (int)AccessTools.Field(typeof(UIStationWindow), "_stationId")?.GetValue(stationWindow); PlanetData pData = GameMain.galaxy.PlanetById(packet.planetId); if (pData?.factory == null || pData?.factory?.transport == null) { if (GameMain.data.galacticTransport.stationPool.Length > packet.stationGId && GameMain.data.galacticTransport.stationPool[packet.stationGId] != null) { // client never was on this planet before or has it unloaded, but has a fake structure created, so update it UpdateSettingsUIBackground(packet, pData, packet.stationGId); } return; } for (int i = 0; i < pData.factory.transport.stationPool.Length; i++) { if (pData.factory.transport.stationPool[i] != null) { int id = ((packet.isStellar == true) ? pData.factory.transport.stationPool[i].gid : pData.factory.transport.stationPool[i].id); if (id == packet.stationGId) { if (pData.factory.transport.stationPool[i].id != _stationId) { // receiving side has the UI closed or another stations UI opened. still update drones, ships, warpers and power consumption for clients and update all for host UpdateSettingsUIBackground(packet, pData, pData.factory.transport.stationPool[i].gid); return; } else { break; } } } } // this locks the patches so we can call vanilla functions without triggering our patches to avoid endless loops using (ILSShipManager.PatchLockILS.On()) { if (packet.settingIndex == StationUI.UIsettings.MaxChargePower) { stationWindow.OnMaxChargePowerSliderValueChange(packet.settingValue); } if (packet.settingIndex == StationUI.UIsettings.MaxTripDrones) { stationWindow.OnMaxTripDroneSliderValueChange(packet.settingValue); } if (packet.settingIndex == StationUI.UIsettings.MaxTripVessel) { stationWindow.OnMaxTripVesselSliderValueChange(packet.settingValue); } if (packet.settingIndex == StationUI.UIsettings.MinDeliverDrone) { stationWindow.OnMinDeliverDroneValueChange(packet.settingValue); } if (packet.settingIndex == StationUI.UIsettings.MinDeliverVessel) { stationWindow.OnMinDeliverVesselValueChange(packet.settingValue); } if (packet.settingIndex == StationUI.UIsettings.WarpDistance) { stationWindow.OnWarperDistanceValueChange(packet.settingValue); } if (packet.settingIndex == StationUI.UIsettings.warperNeeded) { stationWindow.OnWarperNecessaryClick(0); } if (packet.settingIndex == StationUI.UIsettings.includeCollectors) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; AccessTools.Method(typeof(UIStationWindow), "OnIncludeOrbitCollectorClick", args).Invoke(stationWindow, values); } if (packet.settingIndex >= StationUI.UIsettings.setDroneCount && packet.settingIndex <= StationUI.UIsettings.setWarperCount) { StationComponent[] stationPool = pData.factory.transport.stationPool; if (packet.settingIndex == StationUI.UIsettings.setDroneCount) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; if (UIRequestedShipDronWarpChange) { AccessTools.Method(typeof(UIStationWindow), "OnDroneIconClick", args).Invoke(stationWindow, values); UIRequestedShipDronWarpChange = false; } stationPool[_stationId].idleDroneCount = (int)packet.settingValue; } if (packet.settingIndex == StationUI.UIsettings.setShipCount) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; if (UIRequestedShipDronWarpChange) { AccessTools.Method(typeof(UIStationWindow), "OnShipIconClick", args).Invoke(stationWindow, values); UIRequestedShipDronWarpChange = false; } stationPool[_stationId].idleShipCount = (int)packet.settingValue; } if (packet.settingIndex == StationUI.UIsettings.setWarperCount) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; if (UIRequestedShipDronWarpChange) { AccessTools.Method(typeof(UIStationWindow), "OnWarperIconClick", args).Invoke(stationWindow, values); UIRequestedShipDronWarpChange = false; } stationPool[_stationId].warperCount = (int)packet.settingValue; } } /* * the idea is that clients request that they want to apply a change and do so once the server responded with an okay. * the calls to OnItemIconMouseDown() and OnItemIconMouseUp() are blocked for clients and called only from here. */ if (packet.settingIndex == StationUI.UIsettings.addOrRemoveItemFromStorageReq) { StationComponent[] stationPool = pData.factory.transport.stationPool; if (stationPool[_stationId].storage != null) { if (packet.shouldMimick) { BaseEventData mouseEvent = lastMouseEvent; UIStationStorage[] storageUIs = (UIStationStorage[])AccessTools.Field(typeof(UIStationWindow), "storageUIs").GetValue(stationWindow); if (lastMouseEvent != null) { // TODO: change this such that only server sends the response, else clients with a desynced state could change servers storage to a faulty value // issue #249 if (lastMouseEventWasDown) { storageUIs[packet.storageIdx].OnItemIconMouseDown(mouseEvent); StationUI packet2 = new StationUI(packet.stationGId, packet.planetId, packet.storageIdx, StationUI.UIsettings.addOrRemoveItemFromStorageResp, packet.itemId, stationPool[_stationId].storage[packet.storageIdx].count, packet.isStellar); LocalPlayer.SendPacket(packet2); } else { storageUIs[packet.storageIdx].OnItemIconMouseUp(mouseEvent); StationUI packet2 = new StationUI(packet.stationGId, packet.planetId, packet.storageIdx, StationUI.UIsettings.addOrRemoveItemFromStorageResp, packet.itemId, stationPool[_stationId].storage[packet.storageIdx].count, packet.isStellar); LocalPlayer.SendPacket(packet2); } lastMouseEvent = null; } } } } if (packet.settingIndex == StationUI.UIsettings.addOrRemoveItemFromStorageResp) { StationComponent[] stationPool = pData.factory.transport.stationPool; if (stationPool[_stationId].storage != null) { stationPool[_stationId].storage[packet.storageIdx].count = (int)packet.settingValue; } } } } }
public static void EntityFastFillIn_Postfix(PlanetFactory __instance, int entityId) { // belt, splitter, monitor, miner, fractionator, piler: handle by BeltFastFillIn // storage: sync in StorageComponent.AddItemStacked // inserter, powerNode, powerCon, powerAcc: no fill in interaction if (Multiplayer.IsActive && entityId > 0 && __instance.entityPool[entityId].id == entityId) { EntityData entityData = __instance.entityPool[entityId]; if (entityData.tankId > 0) { int tankId = entityData.tankId; TankComponent[] tankPool = __instance.factoryStorage.tankPool; Multiplayer.Session.Network.SendPacketToLocalStar(new TankStorageUpdatePacket(in tankPool[tankId], __instance.planetId)); } if (entityData.assemblerId > 0) { int assemblerId = entityData.assemblerId; AssemblerComponent[] assemblerPool = __instance.factorySystem.assemblerPool; if (assemblerPool[assemblerId].recipeId > 0) { Multiplayer.Session.Network.SendPacketToLocalStar(new AssemblerUpdateStoragePacket(__instance.planetId, assemblerId, assemblerPool[assemblerId].served, assemblerPool[assemblerId].incServed)); } } if (entityData.ejectorId > 0) { int ejectorId = entityData.ejectorId; EjectorComponent[] ejectorPool = __instance.factorySystem.ejectorPool; Multiplayer.Session.Network.SendPacketToLocalStar(new EjectorStorageUpdatePacket(ejectorId, ejectorPool[ejectorId].bulletCount, ejectorPool[ejectorId].bulletInc, __instance.planetId)); } if (entityData.siloId > 0) { int siloId = entityData.siloId; SiloComponent[] siloPool = __instance.factorySystem.siloPool; Multiplayer.Session.Network.SendPacketToLocalStar(new SiloStorageUpdatePacket(siloId, siloPool[siloId].bulletCount, siloPool[siloId].bulletInc, __instance.planetId)); } if (entityData.labId > 0) { int labId = entityData.labId; LabComponent[] labPool = __instance.factorySystem.labPool; if (labPool[labId].researchMode) { for (int matrixId = 0; matrixId < LabComponent.matrixIds.Length; matrixId++) { Multiplayer.Session.Network.SendPacketToLocalStar(new LaboratoryUpdateCubesPacket(labPool[labId].matrixServed[matrixId], labPool[labId].matrixIncServed[matrixId], matrixId, labId, __instance.planetId)); } } else if (labPool[labId].matrixMode) { for (int m = 0; m < labPool[labId].served.Length; m++) { Multiplayer.Session.Network.SendPacketToLocalStar(new LaboratoryUpdateStoragePacket(labPool[labId].served[m], labPool[labId].incServed[m], m, labId, __instance.planetId)); } } } if (entityData.stationId > 0) { int stationId = entityData.stationId; StationComponent stationComponent = __instance.transport.stationPool[stationId]; for (int i = 0; i < stationComponent.storage.Length; i++) { if (stationComponent.storage[i].itemId > 0) { StorageUI packet = new StorageUI(__instance.planetId, stationComponent.id, stationComponent.gid, i, stationComponent.storage[i].count, stationComponent.storage[i].inc); Multiplayer.Session.Network.SendPacket(packet); } } if (!stationComponent.isCollector && !stationComponent.isVeinCollector) { StationUI packet = new StationUI(__instance.planetId, stationComponent.id, stationComponent.gid, StationUI.EUISettings.SetDroneCount, stationComponent.idleDroneCount + stationComponent.workDroneCount); Multiplayer.Session.Network.SendPacket(packet); } if (stationComponent.isStellar && !stationComponent.isCollector && !stationComponent.isVeinCollector) { StationUI packet = new StationUI(__instance.planetId, stationComponent.id, stationComponent.gid, StationUI.EUISettings.SetShipCount, stationComponent.idleShipCount + stationComponent.workShipCount); Multiplayer.Session.Network.SendPacket(packet); } if (stationComponent.isStellar && !stationComponent.isCollector && !stationComponent.isVeinCollector && __instance.gameData.history.logisticShipWarpDrive) { StationUI packet = new StationUI(__instance.planetId, stationComponent.id, stationComponent.gid, StationUI.EUISettings.SetWarperCount, stationComponent.warperCount); Multiplayer.Session.Network.SendPacket(packet); } } if (entityData.powerGenId > 0) { int powerGenId = entityData.powerGenId; PowerGeneratorComponent[] genPool = __instance.powerSystem.genPool; Multiplayer.Session.Network.SendPacketToLocalStar(new PowerGeneratorFuelUpdatePacket(powerGenId, genPool[powerGenId].fuelId, genPool[powerGenId].fuelCount, genPool[powerGenId].fuelInc, __instance.planetId)); if (genPool[powerGenId].gamma) { Multiplayer.Session.Network.SendPacketToLocalStar(new RayReceiverChangeLensPacket(powerGenId, genPool[powerGenId].catalystPoint, genPool[powerGenId].catalystIncPoint, __instance.planetId)); } } if (entityData.powerExcId > 0) { int powerExcId = entityData.powerExcId; PowerExchangerComponent[] excPool = __instance.powerSystem.excPool; Multiplayer.Session.Network.SendPacketToLocalStar(new PowerExchangerStorageUpdatePacket(powerExcId, excPool[powerExcId].emptyCount, excPool[powerExcId].fullCount, __instance.planetId)); } if (entityData.spraycoaterId > 0) { int spraycoaterId = entityData.spraycoaterId; SpraycoaterComponent[] spraycoaterPool = __instance.cargoTraffic.spraycoaterPool; Multiplayer.Session.Network.SendPacketToLocalStar(new SprayerStorageUpdatePacket(spraycoaterPool[spraycoaterId], __instance.planetId)); } } }
/* * Update station settings and drone, ship and warper counts. * * First determine if the local player has the station window opened and handle that accordingly. */ private static void UpdateSettingsUI(StationUI packet) { UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow; StationComponent stationComponent = null; PlanetData planet = GameMain.galaxy?.PlanetById(packet.PlanetId); // If we can't find planet or the factory for said planet, we can just skip this if (planet?.factory?.transport == null) { return; } StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool; StationComponent[] stationPool = planet?.factory?.transport?.stationPool; // Figure out if we're dealing with a PLS or a ILS station stationComponent = packet.StationGId > 0 ? gStationPool[packet.StationGId] : stationPool?[packet.StationId]; if (stationComponent == null) { Log.Error($"UpdateStorageUI: Unable to find requested station on planet {packet.PlanetId} with id {packet.StationId} and gid of {packet.StationGId}"); return; } if (stationWindow == null) { return; } int _stationId = (int)AccessTools.Field(typeof(UIStationWindow), "_stationId")?.GetValue(stationWindow); // Client has no knowledge of the planet, closed the window or // opened a different station, do all updates in the background. if (planet?.factory?.transport == null || stationComponent.id != _stationId) { UpdateSettingsUIBackground(packet, planet, stationComponent); return; } // this locks the patches so we can call vanilla functions without triggering our patches to avoid endless loops using (ILSShipManager.PatchLockILS.On()) { if (packet.SettingIndex == StationUI.EUISettings.MaxChargePower) { stationWindow.OnMaxChargePowerSliderValueChange(packet.SettingValue); } if (packet.SettingIndex == StationUI.EUISettings.MaxTripDrones) { stationWindow.OnMaxTripDroneSliderValueChange(packet.SettingValue); } if (packet.SettingIndex == StationUI.EUISettings.MaxTripVessel) { stationWindow.OnMaxTripVesselSliderValueChange(packet.SettingValue); } if (packet.SettingIndex == StationUI.EUISettings.MinDeliverDrone) { stationWindow.OnMinDeliverDroneValueChange(packet.SettingValue); } if (packet.SettingIndex == StationUI.EUISettings.MinDeliverVessel) { stationWindow.OnMinDeliverVesselValueChange(packet.SettingValue); } if (packet.SettingIndex == StationUI.EUISettings.WarpDistance) { stationWindow.OnWarperDistanceValueChange(packet.SettingValue); } if (packet.SettingIndex == StationUI.EUISettings.WarperNeeded) { stationWindow.OnWarperNecessaryClick(0); } if (packet.SettingIndex == StationUI.EUISettings.IncludeCollectors) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; AccessTools.Method(typeof(UIStationWindow), "OnIncludeOrbitCollectorClick", args).Invoke(stationWindow, values); } if (packet.SettingIndex >= StationUI.EUISettings.SetDroneCount && packet.SettingIndex <= StationUI.EUISettings.SetWarperCount) { if (packet.SettingIndex == StationUI.EUISettings.SetDroneCount) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; if (UIRequestedShipDronWarpChange) { AccessTools.Method(typeof(UIStationWindow), "OnDroneIconClick", args).Invoke(stationWindow, values); UIRequestedShipDronWarpChange = false; } stationComponent.idleDroneCount = (int)packet.SettingValue; } if (packet.SettingIndex == StationUI.EUISettings.SetShipCount) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; if (UIRequestedShipDronWarpChange) { AccessTools.Method(typeof(UIStationWindow), "OnShipIconClick", args).Invoke(stationWindow, values); UIRequestedShipDronWarpChange = false; } stationComponent.idleShipCount = (int)packet.SettingValue; } if (packet.SettingIndex == StationUI.EUISettings.SetWarperCount) { Type[] args = new Type[1]; object[] values = new object[1]; args[0] = typeof(int); values[0] = 0; if (UIRequestedShipDronWarpChange) { AccessTools.Method(typeof(UIStationWindow), "OnWarperIconClick", args).Invoke(stationWindow, values); UIRequestedShipDronWarpChange = false; } stationComponent.warperCount = (int)packet.SettingValue; } } /* * the idea is that clients request that they want to apply a change and do so once the server responded with an okay. * the calls to OnItemIconMouseDown() and OnItemIconMouseUp() are blocked for clients and called only from here. */ if (packet.SettingIndex == StationUI.EUISettings.AddOrRemoveItemFromStorageRequest) { if (stationComponent.storage != null) { if (packet.ShouldMimic) { BaseEventData mouseEvent = LastMouseEvent; UIStationStorage[] storageUIs = (UIStationStorage[])AccessTools.Field(typeof(UIStationWindow), "storageUIs").GetValue(stationWindow); if (LastMouseEvent != null) { // TODO: change this such that only server sends the response, else clients with a desynced state could change servers storage to a faulty value // issue #249 if (LastMouseEventWasDown) { storageUIs[packet.StorageIdx].OnItemIconMouseDown(mouseEvent); StationUI packet2 = new StationUI(packet.PlanetId, packet.StationId, packet.StationGId, packet.StorageIdx, StationUI.EUISettings.AddOrRemoveItemFromStorageResponse, packet.ItemId, stationComponent.storage[packet.StorageIdx].count); LocalPlayer.SendPacket(packet2); } else { storageUIs[packet.StorageIdx].OnItemIconMouseUp(mouseEvent); StationUI packet2 = new StationUI(packet.PlanetId, packet.StationId, packet.StationGId, packet.StorageIdx, StationUI.EUISettings.AddOrRemoveItemFromStorageResponse, packet.ItemId, stationComponent.storage[packet.StorageIdx].count); LocalPlayer.SendPacket(packet2); } LastMouseEvent = null; } } } } if (packet.SettingIndex == StationUI.EUISettings.AddOrRemoveItemFromStorageResponse) { if (stationComponent.storage != null) { stationComponent.storage[packet.StorageIdx].count = (int)packet.SettingValue; } } } }
/** * Updates to a given station that should happen in the background. */ private static void UpdateSettingsUIBackground(StationUI packet, PlanetData planet, StationComponent stationComponent) { StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool; // update drones, ships, warpers and energy consumption for everyone if ((packet.SettingIndex >= StationUI.EUISettings.SetDroneCount && packet.SettingIndex <= StationUI.EUISettings.SetWarperCount) || packet.SettingIndex == StationUI.EUISettings.MaxChargePower) { if (packet.SettingIndex == (int)StationUI.EUISettings.MaxChargePower && planet.factory?.powerSystem != null) { PowerConsumerComponent[] consumerPool = planet.factory.powerSystem.consumerPool; if (consumerPool.Length > stationComponent.pcId) { consumerPool[stationComponent.pcId].workEnergyPerTick = (long)(50000.0 * (double)packet.SettingValue + 0.5); } } if (packet.SettingIndex == StationUI.EUISettings.SetDroneCount) { stationComponent.idleDroneCount = (int)packet.SettingValue; } if (packet.SettingIndex == StationUI.EUISettings.SetShipCount) { stationComponent.idleShipCount = (int)packet.SettingValue; } if (packet.SettingIndex == StationUI.EUISettings.SetWarperCount) { stationComponent.warperCount = (int)packet.SettingValue; } } if (packet.SettingIndex == StationUI.EUISettings.MaxTripDrones) { stationComponent.tripRangeDrones = Math.Cos((double)packet.SettingValue / 180.0 * 3.141592653589793); } if (packet.SettingIndex == StationUI.EUISettings.MaxTripVessel) { double value = packet.SettingValue; if (value > 40.5) { value = 10000.0; } else if (value > 20.5) { value = value * 2f - 20f; } stationComponent.tripRangeShips = 2400000.0 * value; } if (packet.SettingIndex == StationUI.EUISettings.MinDeliverDrone) { int value = (int)(packet.SettingValue * 10f + 0.5f); if (value < 1) { value = 1; } stationComponent.deliveryDrones = value; } if (packet.SettingIndex == StationUI.EUISettings.MinDeliverVessel) { int value = (int)(packet.SettingValue * 10f + 0.5f); if (value < 1) { value = 1; } stationComponent.deliveryShips = value; } if (packet.SettingIndex == StationUI.EUISettings.WarpDistance) { double value = packet.SettingValue; if (value < 1.5) { value = 0.2; } else if (value < 7.5) { value = value * 0.5 - 0.5; } else if (value < 16.5) { value -= 4f; } else if (value < 20.5) { value = value * 2f - 20f; } else { value = 60; } stationComponent.warpEnableDist = 40000.0 * value; } if (packet.SettingIndex == StationUI.EUISettings.WarperNeeded) { stationComponent.warperNecessary = !stationComponent.warperNecessary; } if (packet.SettingIndex == StationUI.EUISettings.IncludeCollectors) { stationComponent.includeOrbitCollector = !stationComponent.includeOrbitCollector; } if (packet.SettingIndex == StationUI.EUISettings.AddOrRemoveItemFromStorageResponse) { if (stationComponent.storage != null) { stationComponent.storage[packet.StorageIdx].count = (int)packet.SettingValue; } } }