protected virtual void client_OperationalStateChangedEvent(IOperational operational, OperationalStateEnum previousOperationState) { lock (this) { if (this.client != null && !this.SessionCheckBox.Enabled) { if (this.client.IsOperational) { this.ConnectCheckBox.Invoke(new SetControlBoolValue(this.SetControlChecked), this.ConnectCheckBox, true); TransportInfo ti = this.client.ProxyTransportInfo; if (this.platform.RegisterSource( new SourceInfo( SourceTypeEnum.HighPriorityLiveFullProvider, ti) )) { this.Message = "Client Proxy connected"; this.clientID = ti.OriginalSenderId.Value.Id; this.client.OperationalStateChangedEvent -= new OperationalStateChangedDelegate(client_OperationalStateChangedEvent); this.Invoke(new SetControlBoolValue(this.SetControlEnable), this.URLTextBox, false); this.Invoke(new SetControlBoolValue(this.SetControlEnable), this.ExpertNameTextBox, false); this.Invoke(new SetControlBoolValue(this.SetControlEnable), this.SessionCheckBox, true); } } } } }
public static void GetStats(ref Building building, out TransportInfo primatyInfo, out TransportInfo secondaryInfo) { var depotAi = building.Info?.m_buildingAI as DepotAI; if (depotAi == null || (depotAi.m_transportInfo == null && depotAi.m_secondaryTransportInfo == null)) { var shelterAi = building.Info?.m_buildingAI as ShelterAI; if (shelterAi == null || shelterAi.m_transportInfo == null) { primatyInfo = null; secondaryInfo = null; } else { primatyInfo = shelterAi.m_transportInfo; secondaryInfo = null; } } else { primatyInfo = depotAi.m_transportInfo; secondaryInfo = depotAi.m_secondaryTransportInfo; } }
public static void Reset() { MetroVehicle = null; MetroTransport = null; TramTransport = null; TramVehicle = null; }
public static void Postfix(TransportInfo ___m_prefab, Vector3 ___m_hitPosition, bool ___m_fixedPlatform, int ___m_hoverStopIndex, int ___m_hoverSegmentIndex, int ___m_mode, ToolBase.ToolErrors ___m_errors, ref DataStore __state) { if (IgnoreHelper.IsIgnored()) { return; } TransportHandler.TrackSimulationStep = false; // Only send when values have changed if (TransportHandler.DidUpdatePaths || __state.hitPos != ___m_hitPosition || __state.fixedP != ___m_fixedPlatform || __state.hoverStop != ___m_hoverStopIndex || __state.hoverSegment != ___m_hoverSegmentIndex || __state.mode != ___m_mode || __state.errors != ___m_errors) { Command.SendToAll(new TransportLineSyncCommand() { HitPosition = ___m_hitPosition, FixedPlatform = ___m_fixedPlatform, HoverStopIndex = ___m_hoverStopIndex, HoverSegmentIndex = ___m_hoverSegmentIndex, Mode = ___m_mode, Errors = ___m_errors, UpdateLines = TransportHandler.DidUpdateLinesNow, UpdatePaths = TransportHandler.DidUpdatePaths }); TransportHandler.DidUpdateLinesNow = false; TransportHandler.DidUpdatePaths = false; } }
public static bool CanAddVehicle(ushort depotID, ref Building depot, TransportInfo transportInfo) { if (depot.Info == null) { return(false); } if (depot.Info.m_buildingAI is DepotAI) { DepotAI buildingAi = depot.Info.m_buildingAI as DepotAI; if (transportInfo.m_vehicleType == buildingAi.m_transportInfo?.m_vehicleType || transportInfo.m_vehicleType == buildingAi.m_secondaryTransportInfo?.m_vehicleType) { int num = (PlayerBuildingAI.GetProductionRate(100, Singleton <EconomyManager> .instance.GetBudget(buildingAi.m_info.m_class)) * buildingAi.m_maxVehicleCount + 99) / 100; return(buildingAi.GetVehicleCount(depotID, ref depot) < num); } } if (depot.Info.m_buildingAI is ShelterAI) { ShelterAI buildingAi = depot.Info.m_buildingAI as ShelterAI; int num = (PlayerBuildingAI.GetProductionRate(100, Singleton <EconomyManager> .instance.GetBudget(buildingAi.m_info.m_class)) * buildingAi.m_evacuationBusCount + 99) / 100; int count = 0; int cargo = 0; int capacity = 0; int outside = 0; CommonBuildingAIReverseDetour.CalculateOwnVehicles(buildingAi, depotID, ref depot, buildingAi.m_transportInfo.m_vehicleReason, ref count, ref cargo, ref capacity, ref outside); return(count < num); } return(false); }
private static Vector3 MinimumVerticalOffset(NetSegment netSegment, TransportInfo secondaryTransport) { return(new Vector3(0, netSegment.Info.m_lanes .Where(l => l.m_vehicleType == secondaryTransport.m_vehicleType) .Select(l => l.m_verticalOffset) .Min(), 0)); }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">Arguments not needed</param> static void Main(string[] args) { // Create transport object that will listen on the following port on the best guessed local address Random rnd = new Random(); int port = rnd.Next(5090, 6090); TransportInfo localTransport = CreateTransport("172.27.0.130", port); // Can also specify an IP if you know the IP to be used. //TransportInfo localTransport = CreateTransport("192.168.20.28", 8989); // Create an object of your SIP handling logic with the created transport SIPApp app = new SIPApp(localTransport); // Create a SIP stack with the proxy address if needed SIPStack stack = CreateStack(app, "alice", "172.30.0.161", 5060); // Register with the specified user URI app.Register("sip:[email protected]"); while (true) { app.Invite("sip:[email protected]"); } // Simple pause so you can test each function / watch the SIP signalling Console.ReadKey(); app.Invite("*****@*****.**"); // Simple pause so you can test each function / watch the SIP signalling Console.ReadKey(); // End the current call (presuming it was accepted) app.EndCurrentCall(); // Send an example IM app.Message("*****@*****.**", "Hello, this is alice testing the SIP library"); Console.ReadKey(); }
/// <summary> /// /// </summary> public void HandleRequest(TransportInfo transportInfo, bool subscribe, DataSubscriptionInfo?info) { if (transportInfo.OriginalSenderId.HasValue == false) { SystemMonitor.Error("Original sender not available in transport info."); return; } lock (this) { if (info.HasValue == false) { _subscriptions.Remove(transportInfo.OriginalSenderId.Value); } else { if (_subscriptions.ContainsKey(transportInfo.OriginalSenderId.Value)) { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair <TransportInfo, DataSubscriptionInfo>(transportInfo, DataSubscriptionInfo.Combine(_subscriptions[transportInfo.OriginalSenderId.Value].Value, subscribe, info.Value)); } else { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair <TransportInfo, DataSubscriptionInfo>(transportInfo, info.Value); } } } }
public static void OnButtonClickedPos(ref TransportInfo __state) { if (__state != Singleton <ToolController> .instance.gameObject.GetComponentInChildren <TransportTool>().m_prefab) { TLMController.instance.LineCreationToolbox.syncForm(); } }
public static ICqrsEngine CreateCqrsEngine(string connectionString, ILogFactory logFactory) { var rabbitMqSettings = new ConnectionFactory { Uri = connectionString }; var transportInfo = new TransportInfo ( rabbitMqSettings.Endpoint.ToString(), rabbitMqSettings.UserName, rabbitMqSettings.Password, "None", "RabbitMq" ); var transports = new Dictionary <string, TransportInfo> { { "RabbitMq", transportInfo } }; return(CreateEngine( logFactory, new MessagingEngine( logFactory, new TransportResolver(transports), new RabbitMqTransportFactory(logFactory) ) )); }
public JsonResult GetPrice(TransportInfo transportInfo) { try { int offerID; var phone = HttpContext.Session.GetString("SessionCustomerPhone"); if (phone == "") { return(Json(new { status = false, msg = "Lütfen Sayfayı yenileyerek tekrar deneyiniz.." })); } transportInfo.CustomerPhone = phone; if (transportInfo.FromRoomCountID == null || transportInfo.FromFloor == null || transportInfo.ToFloor == null) { offerID = _getOfferRepository.CreateOffer(transportInfo, null); return(Json(new { offerID, status = true, price = "Size özel teklif için sizi arıyacağız.." })); } var price = _getOfferRepository.GetPrice(transportInfo); offerID = _getOfferRepository.CreateOffer(transportInfo, price); return(Json(new { offerID, status = true, price = (price + " ₺") })); } catch (Exception e) { return(Json(new { status = false, msg = e })); } }
public static void UnlockCableCarsButton() { UnlockManager.instance.m_properties.m_SubServiceMilestones[(int)ItemClass.SubService.PublicTransportCableCar] = null; for (uint i = 0; i < PrefabCollection <BuildingInfo> .LoadedCount(); i++) { BuildingInfo buildInfo = PrefabCollection <BuildingInfo> .GetLoaded(i); if (buildInfo != null) { if (buildInfo.m_class.m_subService == ItemClass.SubService.PublicTransportCableCar) { buildInfo.m_UnlockMilestone = null; } } } for (uint x = 0; x < PrefabCollection <TransportInfo> .LoadedCount(); x++) { TransportInfo transportInfo = PrefabCollection <TransportInfo> .GetLoaded(x); if (transportInfo != null) { if (transportInfo.m_class.m_subService == ItemClass.SubService.PublicTransportCableCar) { transportInfo.m_UnlockMilestone = null; } } } }
private void OnReleasedForInfo(ushort id, TransportInfo transportInfo) { if (transportInfo == null) { return; } OnDepotRemoved?.Invoke(transportInfo.GetService(), transportInfo.GetSubService(), transportInfo.GetClassLevel()); }
static RetryPolicy() { var ti = new TransportInfo(); _default = new RetryPolicy { Count = ti.RetryCount, Interval = TimeSpan.FromMinutes(ti.RetryInterval) }; }
public static int GetEffectiveBudgetInt(ushort transportLine) { TransportInfo info = Singleton <TransportManager> .instance.m_lines.m_buffer[transportLine].Info; Tuple <float, int, int, float, bool> lineBudget = GetBudgetMultiplierLineWithIndexes(transportLine); int budgetClass = lineBudget.Fifth ? 100 : Singleton <EconomyManager> .instance.GetBudget(info.m_class); return((int)(budgetClass * lineBudget.First)); }
public static TransportSystemDefinition from(TransportInfo info) { if (info == null) { return(default(TransportSystemDefinition)); } return(availableDefinitions.FirstOrDefault(x => x.subService == info.m_class.m_subService && x.vehicleType == info.m_vehicleType)); }
public static ushort[] GetDepots(ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level) { HashSet <ushort> source; TransportInfo info = null; return(_depotMap.TryGetValue(new ItemClassTriplet(service, subService, level), out source) ? source.Where(d => DepotUtil.IsValidDepot(ref BuildingManager.instance.m_buildings.m_buffer[d], ref info, out _, out _, out _)).ToArray() : new ushort[] {}); //we validate here to be compatible with MOM (if MOM sets max vehicle count later than this mod loads) }
/// <summary> /// only sets - catalog.SaveChanges() must be called later at the caller's disgression /// </summary> /// <param name="port"></param> /// <param name="xName"></param> /// <param name="value"></param> /// <returns></returns> public void SetXPersistTransportProperty(SendPort port, string xName, string value) { TransportInfo transportInfo = port.PrimaryTransport; string transportTypeData = transportInfo.TransportTypeData; XDocument transportSettings = XDocument.Parse(transportTypeData); transportSettings.Descendants(xName).Single().Value = value; transportInfo.TransportTypeData = transportSettings.ToString(); }
public static PsTransportInfo FromTransport(TransportInfo transport) { return(new PsTransportInfo { Name = transport.Name, TypeName = transport.TypeName, SampleConnectionString = transport.SampleConnectionString }); }
public void Lock() { for (int index = 0; index < PrefabCollection <TransportInfo> .LoadedCount(); ++index) { TransportInfo loaded = PrefabCollection <TransportInfo> .GetLoaded((uint)index); loaded.m_UnlockMilestone = GetDefaultMilestone(loaded.GetSubService()); } }
public XElement GetTransportProperty(SendPort port, string xName) { TransportInfo transportInfo = port.PrimaryTransport; string transportTypeData = transportInfo.TransportTypeData; XDocument transportSettings = XDocument.Parse(transportTypeData); var ret = transportSettings.Descendants(xName).SingleOrDefault(); return(ret); }
public static bool StartTransfer(DepotAI __instance, ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer) { if (!managedReasons.Contains(reason) || offer.TransportLine == 0) { return(true); } TLMUtils.doLog("START TRANSFER!!!!!!!!"); TransportInfo m_transportInfo = __instance.m_transportInfo; BuildingInfo m_info = __instance.m_info; if (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("m_info {0} | m_transportInfo {1} | Line: {2}", m_info.name, m_transportInfo.name, offer.TransportLine); } if (reason == m_transportInfo.m_vehicleReason || (__instance.m_secondaryTransportInfo != null && reason == __instance.m_secondaryTransportInfo.m_vehicleReason)) { VehicleInfo randomVehicleInfo = null; var tsd = TransportSystemDefinition.from(__instance.m_transportInfo); TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[offer.TransportLine]; TransportInfo.TransportType t = tl.Info.m_transportType; if (TLMLineUtils.hasPrefix(ref tl)) { setRandomBuildingByPrefix(tsd, tl.m_lineNumber / 1000u, ref buildingID); } else { setRandomBuildingByPrefix(tsd, 0, ref buildingID); } TLMUtils.doLog("randomVehicleInfo"); randomVehicleInfo = doModelDraw(offer.TransportLine); if (randomVehicleInfo == null) { randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, m_info.m_class.m_service, m_info.m_class.m_subService, m_info.m_class.m_level); } if (randomVehicleInfo != null) { TLMUtils.doLog("randomVehicleInfo != null"); Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles; __instance.CalculateSpawnPosition(buildingID, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID], ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector); if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort vehicleID, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, reason, false, true)) { TLMUtils.doLog("CreatedVehicle!!!"); randomVehicleInfo.m_vehicleAI.SetSource(vehicleID, ref vehicles.m_buffer[(int)vehicleID], buildingID); randomVehicleInfo.m_vehicleAI.StartTransfer(vehicleID, ref vehicles.m_buffer[(int)vehicleID], reason, offer); } return(false); } } return(true); }
public TransportInfo transportGetInfo(int id) { TransportInfo ret = new TransportInfo(pjsua2PINVOKE.Endpoint_transportGetInfo(swigCPtr, id), true); if (pjsua2PINVOKE.SWIGPendingException.Pending) { throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
ResponseMessage Receive(SubscribeToSourceAccountsUpdatesMessage message) { if (message.TransportInfo.OriginalSenderId.HasValue == false) { SystemMonitor.Error("Failed to establish original sender id."); return(null); } if (message.Subscribe) { List <OrderInfo> orderInfos = new List <OrderInfo>(); lock (this) { _subscribers[message.TransportInfo.OriginalSenderId.Value] = message.TransportInfo; // Send an update of current orderInfo to new subscriber. foreach (KeyValuePair <string, OrderInfo?> pair in _orders) { if (pair.Value.HasValue) { orderInfos.Add(pair.Value.Value); } } } if (orderInfos.Count > 0) { TransportInfo transportInfo = message.TransportInfo.Clone(); GeneralHelper.FireAndForget(delegate() {// Make sure the result of the current call is returned before sending an initial update. Thread.Sleep(500); OrdersInformationUpdateResponseMessage updateMessage = new OrdersInformationUpdateResponseMessage(_accountInfo, orderInfos.ToArray(), true); this.SendResponding(transportInfo, updateMessage); }); } } else { lock (this) { _subscribers.Remove(message.TransportInfo.OriginalSenderId.Value); } } if (message.RequestResponse) { return(new ResponseMessage(true)); } return(null); }
public void openDepotInfo(ushort buildingID, bool secondary) { isLoading = true; WorldInfoPanel.HideAllWorldInfoPanels(); m_buildingIdSelecionado = default(InstanceID); m_buildingIdSelecionado.Building = buildingID; DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI; if (depotAI == null) { return; } depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID)); bool hasPrimary = depotAI.m_transportInfo != null && depotAI.m_maxVehicleCount > 0; bool hasSecondary = depotAI.m_secondaryTransportInfo != null && depotAI.m_maxVehicleCount2 > 0; if (!hasPrimary && !hasSecondary) { closeDepotInfo(null, null); return; } m_secondary = !hasPrimary || (secondary && hasSecondary); TransportInfo currentTransportInfo = m_secondary ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; TransportInfo otherInfo = !m_secondary && depotAI.m_secondaryTransportInfo != null ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo; var tsd = TransportSystemDefinition.from(currentTransportInfo); depotInfoPanel.color = Color.Lerp(TLMCW.getColorForTransportType(tsd.toConfigIndex()), Color.white, 0.5f); lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.normalBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.disabledBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.focusedBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType); lineTransportIconTypeLabel.hoveredBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(otherInfo.m_transportType); if (depotAI.m_secondaryTransportInfo != null) { lineTransportIconTypeLabel.tooltip = string.Format(Locale.Get("TLM_SEE_OTHER_DEPOT"), TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(otherInfo).toConfigIndex())); } else { lineTransportIconTypeLabel.tooltip = ""; } Show(); m_controller.defaultListingLinesPanel.Hide(); updateCheckboxes(); isLoading = false; }
public void eachFrame() { if (lastPrefab != transportTool.m_prefab) { lastPrefab = transportTool.m_prefab; syncForm(); } else { updateUI(true); } }
public JsonResult CreateReservation(TransportInfo transportInfo) { try { //_getOfferRepository.CreateReservation(transportInfo); return(Json(new { status = true })); } catch (Exception e) { return(Json(new { status = false, msg = e })); } }
public static void SelectPrefab(PrefabInfo prefab) { BuildingInfo buildingInfo = prefab as BuildingInfo; NetInfo netInfo = prefab as NetInfo; TransportInfo transportInfo = prefab as TransportInfo; TreeInfo treeInfo = prefab as TreeInfo; PropInfo propInfo = prefab as PropInfo; if (buildingInfo != null) { BuildingTool buildingTool = ToolsModifierControl.SetTool <BuildingTool>(); if (buildingTool != null) { buildingTool.m_prefab = buildingInfo; buildingTool.m_relocate = 0; } } if (netInfo != null) { NetTool netTool = ToolsModifierControl.SetTool <NetTool>(); if (netTool != null) { netTool.Prefab = netInfo; } } if (transportInfo != null) { TransportTool transportTool = ToolsModifierControl.SetTool <TransportTool>(); if (transportTool != null) { transportTool.m_prefab = transportInfo; transportTool.m_building = 0; } } if (treeInfo != null) { TreeTool treeTool = ToolsModifierControl.SetTool <TreeTool>(); if (treeTool != null) { treeTool.m_prefab = treeInfo; treeTool.m_mode = TreeTool.Mode.Single; } } if (propInfo != null) { PropTool propTool = ToolsModifierControl.SetTool <PropTool>(); if (propTool != null) { propTool.m_prefab = propInfo; propTool.m_mode = PropTool.Mode.Single; } } }
public static bool GetNearLines(Vector3 pos, float maxDistance, ref List <ushort> linesFound) { float extendedMaxDistance = maxDistance * 1.3f; int num = Mathf.Max((int)((pos.x - extendedMaxDistance) / 64f + 135f), 0); int num2 = Mathf.Max((int)((pos.z - extendedMaxDistance) / 64f + 135f), 0); int num3 = Mathf.Min((int)((pos.x + extendedMaxDistance) / 64f + 135f), 269); int num4 = Mathf.Min((int)((pos.z + extendedMaxDistance) / 64f + 135f), 269); bool noneFound = true; NetManager nm = Singleton <NetManager> .instance; TransportManager tm = Singleton <TransportManager> .instance; for (int i = num2; i <= num4; i++) { for (int j = num; j <= num3; j++) { ushort num6 = nm.m_nodeGrid[i * 270 + j]; int num7 = 0; while (num6 != 0) { NetInfo info = nm.m_nodes.m_buffer[num6].Info; if ((info.m_class.m_service == ItemClass.Service.PublicTransport)) { ushort transportLine = nm.m_nodes.m_buffer[num6].m_transportLine; var tsd = TransportSystemDefinition.GetDefinitionForLine(transportLine); if (transportLine != 0 && tsd != default && tsd.GetConfig().ShowInLinearMap) { TransportInfo info2 = tm.m_lines.m_buffer[transportLine].Info; if (!linesFound.Contains(transportLine) && (tm.m_lines.m_buffer[transportLine].m_flags & TransportLine.Flags.Temporary) == TransportLine.Flags.None) { float num8 = Vector3.SqrMagnitude(pos - nm.m_nodes.m_buffer[num6].m_position); if (num8 < maxDistance * maxDistance || (info2.m_transportType == TransportInfo.TransportType.Ship && num8 < extendedMaxDistance * extendedMaxDistance)) { linesFound.Add(transportLine); GetNearLines(nm.m_nodes.m_buffer[num6].m_position, maxDistance, ref linesFound); noneFound = false; } } } } num6 = nm.m_nodes.m_buffer[num6].m_nextGridNode; if (++num7 >= 32768) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } } } return(noneFound); }
private static bool CreateIncomingVehicle(bool __result, TransportStationAI __instance, ushort buildingID, ref Building buildingData, ushort startStop, int gateIndex) { if (__instance.m_transportLineInfo != null && (ushort)FindConnectionVehicle.Invoke(__instance, new object[] { buildingID, buildingData, startStop, 3000f }) == 0) { SVMUtils.doLog("START CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name); ServiceSystemDefinition def = ServiceSystemDefinition.from(buildingData.Info).FirstOrDefault(); if (def == null) { SVMUtils.doLog("SSD Não definido para: {0} {1} {2}", buildingData.Info.m_class.m_service, buildingData.Info.m_class.m_subService, buildingData.Info.m_class.m_level); return(false); } SVMUtils.doLog("[{1}] SSD = {0}", def, "CreateIncomingVehicle"); VehicleInfo randomVehicleInfo = ServiceSystemDefinition.availableDefinitions[def].GetAModel(buildingID); SVMUtils.doLog("[{1}] Veh = {0}", randomVehicleInfo?.ToString() ?? "<NULL>", "CreateIncomingVehicle"); if (randomVehicleInfo != null) { ushort num = (ushort)FindConnectionBuilding.Invoke(__instance, new object[] { startStop }); if (num != 0) { Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles; BuildingInfo info = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)num].Info; Randomizer randomizer = default(Randomizer); randomizer.seed = (ulong)((long)gateIndex); Vector3 vector; Vector3 vector2; info.m_buildingAI.CalculateSpawnPosition(num, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)num], ref randomizer, randomVehicleInfo, out vector, out vector2); TransportInfo transportInfo = __instance.m_transportInfo; if (__instance.m_secondaryTransportInfo != null && __instance.m_secondaryTransportInfo.m_class.m_subService == __instance.m_transportLineInfo.m_class.m_subService) { transportInfo = __instance.m_secondaryTransportInfo; } if (randomVehicleInfo.m_vehicleAI.CanSpawnAt(vector) && Singleton <VehicleManager> .instance.CreateVehicle(out ushort num2, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, vector, transportInfo.m_vehicleReason, true, false)) { vehicles.m_buffer[(int)num2].m_gateIndex = (byte)gateIndex; Vehicle[] expr_172_cp_0 = vehicles.m_buffer; ushort expr_172_cp_1 = num2; expr_172_cp_0[(int)expr_172_cp_1].m_flags = (expr_172_cp_0[(int)expr_172_cp_1].m_flags | (Vehicle.Flags.Importing | Vehicle.Flags.Exporting)); randomVehicleInfo.m_vehicleAI.SetSource(num2, ref vehicles.m_buffer[(int)num2], num); randomVehicleInfo.m_vehicleAI.SetSource(num2, ref vehicles.m_buffer[(int)num2], buildingID); randomVehicleInfo.m_vehicleAI.SetTarget(num2, ref vehicles.m_buffer[(int)num2], startStop); SVMUtils.doLog("END CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name); __result = true; return(false); } } } } SVMUtils.doLog("END2 CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name); __result = false; return(false); }
/// <summary> /// /// </summary> public bool SetInitialParameters(ComponentId sourceId, TransportInfo sourceTransportInfo) { if (SourceTransportInfo != null) { SystemMonitor.OperationError("Already initialized."); return false; } SystemMonitor.CheckWarning(sourceId == sourceTransportInfo.OriginalSenderId.Value.Id, "Possible source mis match."); _sourceId = sourceId; if (base.SetRemoteStatusSynchronizationSource(sourceTransportInfo) == false) { return false; } return true; }
private static void OnPreInitializationTI(TransportInfo info) { if (info.name != "Airplane") { return; } info.m_pathVisibility = ItemClass.Availability.GameAndMap; }
/// <summary> /// /// </summary> public void HandleRequest(TransportInfo transportInfo, bool subscribe, DataSubscriptionInfo? info) { if (transportInfo.OriginalSenderId.HasValue == false) { SystemMonitor.Error("Original sender not available in transport info."); return; } lock (this) { if (info.HasValue == false) { _subscriptions.Remove(transportInfo.OriginalSenderId.Value); } else { if (_subscriptions.ContainsKey(transportInfo.OriginalSenderId.Value)) { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair<TransportInfo,DataSubscriptionInfo>(transportInfo, DataSubscriptionInfo.Combine(_subscriptions[transportInfo.OriginalSenderId.Value].Value, subscribe, info.Value)); } else { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair<TransportInfo, DataSubscriptionInfo>(transportInfo, info.Value); } } } }
/// <summary> /// /// </summary> public bool UnRegister(SourceTypeEnum? sourceType, TransportInfo info) { lock (this) { for (int i = _sources.Count - 1; i >= 0; i--) { if (_sources[i].ComponentId == info.OriginalSenderId.Value.Id) { if (sourceType.HasValue == false || sourceType.Value == _sources[i].SourceType) { _sources.RemoveAt(i); } } } } return true; }
private bool CanMoveStop(TransportInfo info, ushort sourceLine, int moveIndex, Vector3 movePos) { return sourceLine != 0 && Singleton<TransportManager>.instance.m_lines.m_buffer[(int)sourceLine].CanMoveStop(sourceLine, moveIndex, movePos); }
void SendQuoteUpdate(TransportInfo[] receivers, DataSessionInfo session) { DataSourceStub.IImplementation implementation = Implementation; if (implementation == null) { return; } QuoteUpdateMessage message = new QuoteUpdateMessage(session, implementation.GetQuoteUpdate(session), true); SendRespondingToMany(receivers, message); }
ResponceMessage Receive(UnSubscribeMessage message) { lock (this) { _subscriberTransportMessageInfo = null; } if (message.RequestResponce) { return new ResponceMessage(true); } return null; }
/// <summary> /// Un initialize manager, notify subsribers, clear resources. /// </summary> public void UnInitialize() { TracerHelper.TraceEntry(); ChangeOperationalState(OperationalStateEnum.UnInitialized); lock (this) { if (_subscriberTransportMessageInfo != null) {// Send update to subscriber to let him now we are closing down. this.SendResponding(_subscriberTransportMessageInfo, new SubscriptionTerminatedMessage()); _subscriberTransportMessageInfo = null; } } // Give time to the termination message to arrive. System.Threading.Thread.Sleep(1000); if (_integrationServer != null && Arbiter != null) { Arbiter.RemoveClient(_integrationServer); } }
private bool IsPlacementRelevant(TransportInfo info) { throw new NotImplementedException("IsPlacementRelevant is target of redirection and is not implemented."); }
private bool CanAddStop(TransportInfo info, ushort sourceLine, int addIndex, Vector3 addPos) { return sourceLine == 0 || Singleton<TransportManager>.instance.m_lines.m_buffer[(int)sourceLine].CanAddStop(sourceLine, addIndex, addPos); }
private string BuildRandomName(ushort lineNumber, TransportInfo.TransportType transportType, List<string> districts, int stopCount) { // todo could this be localized? try { if (transportType == TransportInfo.TransportType.Train) { if (districts.Count == 1) { if (districts[0] == string.Empty) { return string.Format("#{0} {1} Shuttle", lineNumber, districts[0]); } var rnd = Random.value; if (rnd <= .33f) { return string.Format("#{0} {1} Limited", lineNumber, districts[0]); } if (rnd <= .66f) { return string.Format("#{0} {1} Service", lineNumber, districts[0]); } return string.Format("#{0} {1} Shuttle", lineNumber, districts[0]); } if (districts.Count == 2) { if (string.IsNullOrEmpty(districts[0]) || string.IsNullOrEmpty(districts[1])) { return string.Format("#{0} {1} Shuttle", lineNumber, districts[0]); } var rnd = Random.value; if (rnd <= .33f) { return string.Format("#{0} {1}&{2}", lineNumber, districts[0].Substring(0, 1), districts[1].Substring(0, 1)); } if (rnd <= .5) { return string.Format("#{0} {1} Zephr", lineNumber, districts[0].Substring(0, 1)); } if (rnd <= .7) { return string.Format("#{0} {1} Flyer", lineNumber, districts[0].Substring(0, 1)); } return string.Format("#{0} {1} & {2}", lineNumber, districts[0], districts[1]); } return string.Format("#{0} Unlimited", lineNumber); } if (transportType == TransportInfo.TransportType.Bus || transportType == TransportInfo.TransportType.Metro) { if (districts.Count == 1) { if (string.IsNullOrEmpty(districts[0])) { return string.Format("#{0} Line", lineNumber); } return string.Format("#{0} {1} Local", lineNumber, districts[0]); } if (districts.Count == 2 && string.IsNullOrEmpty(districts[0]) && string.IsNullOrEmpty(districts[1])) return string.Format("#{0} Line", lineNumber); if (districts.Count == 2 && stopCount <= 4) return string.Format("#{0} {1} / {2} Express", lineNumber, districts[0], districts[1]); if (districts.Count == 2) return string.Format("#{0} {1} / {2} Line", lineNumber, districts[0], districts[1]); return string.Format("#{0} Line", lineNumber); } } catch (Exception ex) { // if we get an exception we'll just drop back to Line number and color name logger.Error(ex.ToString()); } return string.Format("#{0} Line", lineNumber); }
/// <summary> /// Constructor. /// </summary> public SourceInfo(ComponentId componentId, SourceTypeEnum sourceType) { _componentId = componentId; _transportInfo = null; _sourceType = sourceType; }
/// <summary> /// Will unsubscribe to previous one. /// </summary> protected bool SetRemoteStatusSynchronizationSource(TransportInfo sourceTransportInfo) { lock (this) { if (_remoteStatusSynchronizationSource != null) { SubscribeToOperationalStateChangesMessage message = new SubscribeToOperationalStateChangesMessage(false); message.RequestResponse = false; SendResponding(_remoteStatusSynchronizationSource, message); } _remoteStatusSynchronizationSource = sourceTransportInfo; } bool result = true; if (sourceTransportInfo != null) { ResponseMessage response = SendAndReceiveResponding<ResponseMessage>(sourceTransportInfo, new SubscribeToOperationalStateChangesMessage(true)); result = response != null && response.OperationResult; } TracerHelper.TraceEntry(this.GetType().Name + ", Remote synchronization source " + sourceTransportInfo.OriginalSenderId.Value.Id.Name + " assinged - " + result.ToString()); return result; }
public TransportInfo transportGetInfo(int id) { TransportInfo ret = new TransportInfo(pjsua2PINVOKE.Endpoint_transportGetInfo(swigCPtr, id), true); if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); return ret; }
void SendDataHistoryUpdate(TransportInfo[] receivers, DataSessionInfo session, DataHistoryRequest request) { DataSourceStub.IImplementation implementation = Implementation; if (implementation == null) { return; } DataHistoryUpdate response = implementation.GetDataHistoryUpdate(session, request); SendRespondingToMany(receivers, new DataHistoryUpdateMessage(session, response, response != null)); }
ResponceMessage Receive(SubscribeMessage message) { TracerHelper.TraceEntry(); lock (this) { if (_subscriberTransportMessageInfo != null) {// Notify existing subscriber he lost control. this.SendResponding(_subscriberTransportMessageInfo, new SubscriptionTerminatedMessage()); _subscriberTransportMessageInfo = null; } _subscriberTransportMessageInfo = message.TransportInfo.Clone(); } RegisterSource(); if (message.RequestResponce) { return new ResponceMessage(true); } return null; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TransportInfo obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
/// <summary> /// /// </summary> /// <param name="singleThreadMode"></param> public OperationalTransportClient(SerializationInfo info, StreamingContext context) : base(info, context) { _statusSynchronizationEnabled = info.GetBoolean("statusSynchronizationEnabled"); _persistedRemoteStatusSynchronizationSource = (TransportInfo)info.GetValue("remoteStatusSynchronizationSource", typeof(TransportInfo)); }
void Receive(RegisterSourceMessage message) { _proxyTransportInfo = message.TransportInfo; RegisterSourceMessage localRegistrationMessage = new RegisterSourceMessage( message.SourceType.Value, message.Register); localRegistrationMessage.RequestResponce = false; this.Send(localRegistrationMessage); if (OperationalState != OperationalStateEnum.Operational) { if (OperationalState == OperationalStateEnum.Initializing || OperationalState == OperationalStateEnum.Initialized) { ChangeOperationalState(OperationalStateEnum.Operational); } else { SystemMonitor.OperationError("Adapter received a subscription confirmation, but not in expected state."); } } }
private int GetLineCount(Vector3 stopPosition, Vector3 stopDirection, TransportInfo.TransportType transportType) { NetManager instance = Singleton<NetManager>.instance; TransportManager instance2 = Singleton<TransportManager>.instance; stopDirection.Normalize(); Segment3 segment = new Segment3(stopPosition - stopDirection * 16f, stopPosition + stopDirection * 16f); Vector3 vector = segment.Min(); Vector3 vector2 = segment.Max(); int num = Mathf.Max((int)((vector.x - 4f) / 64f + 135f), 0); int num2 = Mathf.Max((int)((vector.z - 4f) / 64f + 135f), 0); int num3 = Mathf.Min((int)((vector2.x + 4f) / 64f + 135f), 269); int num4 = Mathf.Min((int)((vector2.z + 4f) / 64f + 135f), 269); int num5 = 0; for (int i = num2; i <= num4; i++) { for (int j = num; j <= num3; j++) { ushort num6 = instance.m_nodeGrid[i * 270 + j]; int num7 = 0; while (num6 != 0) { ushort transportLine = instance.m_nodes.m_buffer[(int)num6].m_transportLine; if (transportLine != 0) { TransportInfo info = instance2.m_lines.m_buffer[(int)transportLine].Info; if (info.m_transportType == transportType && (instance2.m_lines.m_buffer[(int)transportLine].m_flags & TransportLine.Flags.Temporary) == TransportLine.Flags.None && segment.DistanceSqr(instance.m_nodes.m_buffer[(int)num6].m_position) < 16f) { num5++; } } num6 = instance.m_nodes.m_buffer[(int)num6].m_nextGridNode; if (++num7 >= 32768) { CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } } } return num5; }
private bool EnsureTempLine(TransportInfo info, ushort sourceLine, int moveIndex, int addIndex, Vector3 addPos, bool fixedPlatform) { TransportManager instance = Singleton<TransportManager>.instance; if (this.m_tempLine != 0) { if ((instance.m_lines.m_buffer[(int)this.m_tempLine].m_flags & TransportLine.Flags.Temporary) == TransportLine.Flags.None) { this.m_tempLine = 0; this.SetEditLine(0, true); } else if (instance.m_lines.m_buffer[(int)this.m_tempLine].Info != info) { instance.ReleaseLine(this.m_tempLine); this.m_tempLine = 0; this.SetEditLine(0, true); } } if (this.m_tempLine == 0) { for (int i = 1; i < 256; i++) { if ((instance.m_lines.m_buffer[i].m_flags & TransportLine.Flags.Temporary) != TransportLine.Flags.None) { if (instance.m_lines.m_buffer[i].Info != info) { instance.ReleaseLine((ushort)i); } else { this.m_tempLine = (ushort)i; this.SetEditLine(sourceLine, true); } break; } } } ushort tempLine = this.m_tempLine; bool flag = this.m_tempLine == 0 && Singleton<TransportManager>.instance.CreateLine(out tempLine, ref Singleton<SimulationManager>.instance.m_randomizer, info, false); this.m_tempLine = tempLine; if (flag) { TransportLine[] expr_141_cp_0 = instance.m_lines.m_buffer; ushort expr_141_cp_1 = this.m_tempLine; expr_141_cp_0[(int)expr_141_cp_1].m_flags = (expr_141_cp_0[(int)expr_141_cp_1].m_flags | TransportLine.Flags.Temporary); this.SetEditLine(sourceLine, true); } if (this.m_tempLine != 0) { this.SetEditLine(sourceLine, false); if (this.m_lastMoveIndex != moveIndex || this.m_lastAddIndex != addIndex || this.m_lastAddPos != addPos) { if (this.m_lastAddIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].RemoveStop(this.m_tempLine, this.m_lastAddIndex)) { this.m_lastAddIndex = -2; this.m_lastAddPos = Vector3.zero; } if (this.m_lastMoveIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].MoveStop(this.m_tempLine, this.m_lastMoveIndex, this.m_lastMovePos, fixedPlatform)) { this.m_lastMoveIndex = -2; this.m_lastMovePos = Vector3.zero; } instance.m_lines.m_buffer[(int)this.m_tempLine].CopyMissingPaths(sourceLine); Vector3 lastMovePos; if (moveIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].MoveStop(this.m_tempLine, moveIndex, addPos, fixedPlatform, out lastMovePos)) { this.m_lastMoveIndex = moveIndex; this.m_lastMovePos = lastMovePos; this.m_lastAddPos = addPos; } if (addIndex != -2 && instance.m_lines.m_buffer[(int)this.m_tempLine].AddStop(this.m_tempLine, addIndex, addPos, fixedPlatform)) { this.m_lastAddIndex = addIndex; this.m_lastAddPos = addPos; } } instance.m_lines.m_buffer[(int)this.m_tempLine].m_color = instance.m_lines.m_buffer[(int)sourceLine].m_color; TransportLine[] expr_327_cp_0 = instance.m_lines.m_buffer; ushort expr_327_cp_1 = this.m_tempLine; expr_327_cp_0[(int)expr_327_cp_1].m_flags = (expr_327_cp_0[(int)expr_327_cp_1].m_flags & ~TransportLine.Flags.Hidden); if ((instance.m_lines.m_buffer[(int)sourceLine].m_flags & TransportLine.Flags.CustomColor) != TransportLine.Flags.None) { TransportLine[] expr_36C_cp_0 = instance.m_lines.m_buffer; ushort expr_36C_cp_1 = this.m_tempLine; expr_36C_cp_0[(int)expr_36C_cp_1].m_flags = (expr_36C_cp_0[(int)expr_36C_cp_1].m_flags | TransportLine.Flags.CustomColor); } else { TransportLine[] expr_398_cp_0 = instance.m_lines.m_buffer; ushort expr_398_cp_1 = this.m_tempLine; expr_398_cp_0[(int)expr_398_cp_1].m_flags = (expr_398_cp_0[(int)expr_398_cp_1].m_flags & ~TransportLine.Flags.CustomColor); } return true; } this.SetEditLine(0, false); return false; }
private bool GetStopPosition(TransportInfo info, ushort segment, ushort building, ushort firstStop, ref Vector3 hitPos, out bool fixedPlatform) { bool toggleSnapTarget = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); fixedPlatform = false; if (segment != 0) { NetManager instance = Singleton<NetManager>.instance; if (!toggleSnapTarget && (instance.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None) { building = NetSegment.FindOwnerBuilding(segment, 363f); if (building != 0) { BuildingManager instance2 = Singleton<BuildingManager>.instance; BuildingInfo info2 = instance2.m_buildings.m_buffer[(int)building].Info; TransportInfo transportLineInfo = info2.m_buildingAI.GetTransportLineInfo(); if (transportLineInfo != null && transportLineInfo.m_transportType == info.m_transportType) { segment = 0; } else { building = 0; } } } Vector3 point; int num; float num2; Vector3 vector; int num3; float num4; if (segment != 0 && instance.m_segments.m_buffer[(int)segment].GetClosestLanePosition(hitPos, NetInfo.LaneType.Pedestrian, VehicleInfo.VehicleType.None, out point, out num, out num2) && instance.m_segments.m_buffer[(int)segment].GetClosestLanePosition(point, NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle, info.m_vehicleType, out vector, out num3, out num4)) { PathUnit.Position pathPos; pathPos.m_segment = segment; pathPos.m_lane = (byte)num3; pathPos.m_offset = 128; NetInfo.Lane lane = instance.m_segments.m_buffer[(int)segment].Info.m_lanes[num3]; if (!lane.m_allowStop) { return false; } float num5 = lane.m_stopOffset; if ((instance.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Invert) != NetSegment.Flags.None) { num5 = -num5; } uint laneID = PathManager.GetLaneID(pathPos); Vector3 vector2; instance.m_lanes.m_buffer[(int)((UIntPtr)laneID)].CalculateStopPositionAndDirection((float)pathPos.m_offset * 0.003921569f, num5, out hitPos, out vector2); fixedPlatform = true; return true; } } if (!toggleSnapTarget && building != 0) { VehicleInfo randomVehicleInfo = Singleton<VehicleManager>.instance.GetRandomVehicleInfo(ref Singleton<SimulationManager>.instance.m_randomizer, info.m_class.m_service, info.m_class.m_subService, info.m_class.m_level); if (randomVehicleInfo != null) { BuildingManager instance3 = Singleton<BuildingManager>.instance; BuildingInfo info3 = instance3.m_buildings.m_buffer[(int)building].Info; if (info3.m_buildingAI.GetTransportLineInfo() != null) { Vector3 vector3 = Vector3.zero; int num6 = 1000000; for (int i = 0; i < 12; i++) { Randomizer randomizer = new Randomizer(i); Vector3 vector4; Vector3 a; info3.m_buildingAI.CalculateSpawnPosition(building, ref instance3.m_buildings.m_buffer[(int)building], ref randomizer, randomVehicleInfo, out vector4, out a); int lineCount = this.GetLineCount(vector4, a - vector4, info.m_transportType); if (lineCount < num6) { vector3 = vector4; num6 = lineCount; } } if (firstStop != 0) { Vector3 position = Singleton<NetManager>.instance.m_nodes.m_buffer[(int)firstStop].m_position; if (Vector3.SqrMagnitude(position - vector3) < 16384f && instance3.FindBuilding(vector3, 128f, info.m_class.m_service, info.m_class.m_subService, Building.Flags.None, Building.Flags.None) == building) { hitPos = position; return true; } } hitPos = vector3; return true; } } } return false; }
/// <summary> /// Constructor. /// </summary> public SourceInfo(SourceTypeEnum sourceType, TransportInfo info) { _sourceType = sourceType; _transportInfo = info; _componentId = _transportInfo.OriginalSenderId.Value.Id; }