public void ProcessPacket(StationUI packet, NebulaConnection conn) { Player player = playerManager.GetPlayer(conn); // if a user adds/removes a ship, drone or warper or changes max power input broadcast to everyone. if ((packet.settingIndex == StationUI.UIsettings.MaxChargePower || packet.settingIndex == StationUI.UIsettings.setDroneCount || packet.settingIndex == StationUI.UIsettings.setShipCount || packet.settingIndex == StationUI.UIsettings.setWarperCount) && player != null && StationUIManager.UpdateCooldown == 0) { playerManager.SendPacketToAllPlayers(packet); } else if (StationUIManager.UpdateCooldown == 0 || !packet.isStorageUI) { List <NebulaConnection> subscribers = StationUIManager.GetSubscribers(packet.stationGId); for (int i = 0; i < subscribers.Count; i++) { if (subscribers[i] != null) { if (subscribers[i] == conn) { /* * as we block the normal method for the client he must run it once he receives this packet. * but only the one issued the request should do it, we indicate this here */ packet.shouldMimick = true; } subscribers[i].SendPacket(packet); } } } // always update values for host SimulatedWorld.OnStationUIChange(packet); }
public void ProcessPacket(StationUI packet, NebulaConnection conn) { Player player = playerManager.GetPlayer(conn); // if a user adds/removes a ship, drone or warper broadcast to everyone. if ((packet.settingIndex == 0 || packet.settingIndex == 8 || packet.settingIndex == 9 || packet.settingIndex == 10) && player != null && StationUIManager.UpdateCooldown == 0) { playerManager.SendPacketToAllPlayers(packet); } else if (StationUIManager.UpdateCooldown == 0 || !packet.isStorageUI) { List <NebulaConnection> subscribers = StationUIManager.GetSubscribers(packet.stationGId); for (int i = 0; i < subscribers.Count; i++) { if (subscribers[i] != null) { if (subscribers[i] == conn) { packet.shouldMimick = true; } Debug.Log("sending packet to subscriber"); subscribers[i].SendPacket(packet); } } } SimulatedWorld.OnStationUIChange(packet); }
public override void ProcessPacket(StationUI packet, NebulaConnection conn) { if (IsHost) { // if a user adds/removes a ship, drone or warper or changes max power input broadcast to everyone. if (StationUIManager.UpdateCooldown == 0 && (packet.SettingIndex == StationUI.EUISettings.MaxChargePower || packet.SettingIndex == StationUI.EUISettings.SetDroneCount || packet.SettingIndex == StationUI.EUISettings.SetShipCount || packet.SettingIndex == StationUI.EUISettings.SetWarperCount) ) { // this is the SendPacketToAllPlayers() logic but we need to set the mimic flag here. using (playerManager.GetConnectedPlayers(out var connectedPlayers)) { foreach (var kvp in connectedPlayers) { Player p = kvp.Value; packet.ShouldMimic = p.Connection == conn; p.SendPacket(packet); } } } else if (packet.SettingIndex == StationUI.EUISettings.AddOrRemoveItemFromStorageResponse) { // if someone adds or removes items by hand broadcast to every player on that planet Player player = playerManager.GetPlayer(conn); if (player != null) { playerManager.SendPacketToPlanet(packet, player.Data.LocalPlanetId); } } else if (StationUIManager.UpdateCooldown == 0 || !packet.IsStorageUI) { List <NebulaConnection> subscribers = StationUIManager.GetSubscribers(packet.PlanetId, packet.StationId, packet.StationGId); for (int i = 0; i < subscribers.Count; i++) { if (subscribers[i] != null) { /* * as we block the normal method for the client he must run it once he receives this packet. * but only the one issued the request should do it, we indicate this here */ packet.ShouldMimic = subscribers[i] == conn; subscribers[i].SendPacket(packet); } } } // always update values for host, but he does not need to rely on the mimic flag (infact its bad for him) packet.ShouldMimic = false; SimulatedWorld.OnStationUIChange(packet); } if (IsClient) { SimulatedWorld.OnStationUIChange(packet); } }
public void ProcessPacket(StationSubscribeUIUpdates packet, NebulaConnection conn) { if (packet.subscribe) { StationUIManager.AddSubscriber(packet.stationGId, conn); } else { StationUIManager.RemoveSubscriber(packet.stationGId, conn); } }
public static void Initialize() { StationUIManager.Initialize(); FactoryManager.Initialize(); PlanetManager.Initialize(); Initialized = true; ExitingMultiplayerSession = false; using (GetRemotePlayersModels(out var remotePlayersModels)) { remotePlayersModels.Clear(); } }
public override void ProcessPacket(StationSubscribeUIUpdates packet, NebulaConnection conn) { if (IsClient) { return; } if (packet.Subscribe) { StationUIManager.AddSubscriber(packet.PlanetId, packet.StationId, packet.StationGId, conn); } else { StationUIManager.RemoveSubscriber(packet.PlanetId, packet.StationId, packet.StationGId, conn); } }
public static void GameTick_Postfix(GameData __instance, long time) { if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient) { if (SimulatedWorld.Initialized) { StationUIManager.DecreaseCooldown(); } return; } // call StationComponent::InternalTickRemote() from here, see StationComponent_Patch.cs for info int timeGene = (int)(time % 60L); if (timeGene < 0) { timeGene += 60; } float dt = 0.016666668f; GameHistoryData history = GameMain.history; float shipSailSpeed = history.logisticShipSailSpeedModified; float shipWarpSpeed = (!history.logisticShipWarpDrive) ? shipSailSpeed : history.logisticShipWarpSpeedModified; int shipCarries = history.logisticShipCarries; StationComponent[] gStationPool = __instance.galacticTransport.stationPool; AstroPose[] astroPoses = __instance.galaxy.astroPoses; VectorLF3 relativePos = __instance.relativePos; Quaternion relativeRot = __instance.relativeRot; bool starmap = UIGame.viewMode == EViewMode.Starmap; foreach (StationComponent stationComponent in GameMain.data.galacticTransport.stationPool) { if (stationComponent != null && stationComponent.isStellar) { //Debug.Log("enter " + stationComponent.gid + " (" + GameMain.galaxy.PlanetById(stationComponent.planetId).displayName + ")"); StationComponent_Transpiler.ILSUpdateShipPos(stationComponent, timeGene, dt, shipSailSpeed, shipWarpSpeed, shipCarries, gStationPool, astroPoses, relativePos, relativeRot, starmap, null); } } }