void Start() { travelData = new TravelData(); moverData = GetComponent <MoverData>(); duelData = GetComponent <DuelData>(); healthData = GetComponent <Health>(); }
private static Tuple <ClientSet <PickupDeliveryClient>, TravelData> LoadTaillardClients(StreamReader reader) { int clients = int.Parse(reader.ReadLine().Trim()); List <double> deliveryDemand = new List <double>(); List <Tuple <double, double> > locations = new List <Tuple <double, double> >(); Regex clientsexp = new Regex(@"(?<id>\d+)\s+(?<x>\d+)\s+(?<y>\d+)\s+(?<dem>\d+)"); for (int i = 0; i < clients + 1; i++) { string line = reader.ReadLine().Trim(); Match m = clientsexp.Match(line); deliveryDemand.Add(double.Parse(m.Groups["dem"].Value)); locations.Add(new Tuple <double, double>(double.Parse(m.Groups["x"].Value), double.Parse(m.Groups["y"].Value))); } ClientSet <PickupDeliveryClient> clientSet = new ClientSet <PickupDeliveryClient>(); for (int i = 1; i < clients + 1; i++) { PickupDeliveryClient c = new PickupDeliveryClient(i, deliveryDemand[i], 0); clientSet.Add(c); } TravelData matrix = LoadTaillarTravelMatrix(locations); return(new Tuple <ClientSet <PickupDeliveryClient>, TravelData>(clientSet, matrix)); }
public static VRPSimultaneousPickupDelivery LoadSalhiNagyProblem(string path, int fleet, bool serieX) { //formato del fichero //clientes capacidad tiempo-maximo tiempo-ruptura //depot-x depot-y //para cada clietne //x y demand int id = ParseNagySalhiName(path); StreamReader reader = new StreamReader(path); var sp = SalhiNagyProblemSpecification(reader); int clientAmount = sp.Item1; int vehicleCapacity = sp.Item2; List <Tuple <double, double, double> > clientsInfo = LoadClientInfo(reader, clientAmount); TravelData matrix = BuildTravelCostMatrix(clientsInfo); ClientSet <PickupDeliveryClient> clientSet = BuildClientSet(clientsInfo, serieX); Fleet vehicles = Fleet.CreateHomogeneousFleet(fleet, vehicleCapacity); reader.Close(); VRPSimultaneousPickupDelivery problem = new VRPSimultaneousPickupDelivery(clientSet, vehicles, matrix); string serie = (serieX) ? "X" : "Y"; problem.ProblemName = string.Format("CMT{0}-{1}-{2}{3}", id, clientAmount, fleet, serie); return(problem); }
public SquadSave(string name, string ident, Vector2Int location, TravelData data, bool atStructure) { this.name = name; this.ident = ident; this.location = location; this.data = data; this.atStructure = atStructure; }
public TravelData(TravelData origin) { start = origin.start; end = origin.end; current = origin.current; tickProgress = origin.tickProgress; maxTicks = origin.maxTicks; traveling = origin.traveling; reverse = origin.reverse; }
public virtual XElement ToXMLFormat() { TravelData td = new TravelData(TravelDistance); XElement node = new XElement("vrp", new XAttribute("problemName", ProblemName), Clients.ToXmlFormat(), Vehicles.ToXMLFormat(), td.ToXMLFormat()); return(node); }
public async Task <Response> CreateTravelAlternatives(TravelData travelData) { await GetRoutes(); await GetRouteTables(); var travelTimeStamps = CalculateTravelTimeStamps(travelData); var travelTime = CalculateTravelTime(travelData); var totalPrice = CalculateTotalPrice(travelData, travelTime); var routeLabel = GetRouteLabel(travelData); return(new Response(travelTimeStamps, travelTime, totalPrice, routeLabel)); }
protected VehicleRoutingProblem(string path) { if (Path.GetExtension(path) != ".xml") { throw new ArgumentException(); } XElement document = XElement.Load(path); var data = TravelData.LoadFromXML(document); TravelDistance = data.Data; ProblemName = document.Attribute("problemName").Value; //TODO: falta leer los datos de la flota }
public async Task <ActionResult> GetTravelAlternatives(TravelData travelData) { try { Response response = await _dataHandler.CreateTravelAlternatives(travelData); return(Ok(response)); } catch (Exception ex) { _log.LogError("Unable to get Travel Alternatives from Database: " + ex); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }
// IDEA: Store regex expressions as static constants, use for models and send to client public static bool ValidateTotalPrice(Ticket ticket, DataHandler _dataHandler) { // Start and End variables of Ticket contains the time + the stop name. Extract the stop names first var startSplit = ticket.Start.Split(" "); var start = ""; for (var i = 1; i < startSplit.Length; i++) { if (i > 1) { start += " "; } start += startSplit[i]; } var endSplit = ticket.End.Split(" "); var end = ""; for (var i = 1; i < endSplit.Length; i++) { if (i > 1) { end += " "; } end += endSplit[i]; } TravelData travelData = new TravelData { TravelFrom = start, TravelTo = end, Travellers = FormatPassengers(ticket.Passengers) }; // Verify that the travel time is correct if (ticket.TravelTime.CompareTo(_dataHandler.CalculateTravelTime(travelData)) != 0) { return(false); } // Verify that the total price is correct if (ticket.TotalPrice.CompareTo(_dataHandler.CalculateTotalPrice(travelData, ticket.TravelTime)) != 0) { return(false); } return(true); }
public Squad(User owner, SquadSave save) { this.owner = owner; name = save.name; ident = save.ident; location = save.location; atStructure = save.atStructure; if (atStructure) if (GameServer.Instance.Structures.OpExists(location)) defendedStructure = GameServer.Instance.Structures.GetStructure(location); else atStructure = false; if (!atStructure && save.data != null) { data = new TravelData(save.data); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); _addressText = FindViewById <TextView>(Resource.Id.address_text); _locationText = FindViewById <TextView>(Resource.Id.location_text); FindViewById <TextView>(Resource.Id.search_gas_button).Click += SearchGas_OnClick; List <Place> places = new List <Place> (); markers = new List <Marker> (); Algorithm algorithm = new Algorithm(); Task <List <Place> > result = Task.Run(() => algorithm.Run()); Task.WaitAll(result); places = result.Result; markPlaces(places); MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map); Android.Gms.Maps.GoogleMap map = mapFrag.Map; map.MarkerClick += MapMarkerClick; GeoPoint origin = Algorithm.getCurrentLocation(); GeoPoint endPoint = Algorithm.getFinalDestination(); string transportationMethod = "driving"; Task <TravelData> result2 = Task.Run(() => algorithm.getOriginalRoute(transportationMethod, origin, endPoint)); originalRoute = result2.Result; Task <TravelData> result3 = Task.Run(() => algorithm.getPitStopRoute(transportationMethod, origin, places[1].Location, endPoint)); TravelData pitStopRoute = result3.Result; polyLines = new List <Polyline> (); drawMark("origin", origin); drawMark("finalDestionation", endPoint); drawRoute(originalRoute, true); InitializeLocationManager(); }
Vector3[] GeneratePath() { var myPos = transform.position; var targetPos = go.transform.position; Vector3[] positions = new Vector3[3]; positions[0] = myPos; Vector3 middlePoint = new Vector3(); middlePoint.x = (myPos.x + targetPos.x) / 2; middlePoint.y = (myPos.y + targetPos.y) / 2; if (data.weaponType == DamageData.WeaponType.Bomb) { if (myPos.y > targetPos.y) { middlePoint.y = myPos.y + Vector2.Distance(myPos, targetPos) / 4; } else { middlePoint.y = targetPos.y + Vector2.Distance(myPos, targetPos) / 4; } } positions[1] = middlePoint; var posY = go.transform.position.y + 10f; float timeProjWillStayInAir = 0f; timeProjWillStayInAir = Vector2.Distance(myPos, targetPos); timeProjWillStayInAir = timeProjWillStayInAir / data.range; timeProjWillStayInAir = timeProjWillStayInAir * data.maxTimeProjectileStaysInAir; TravelData ts = go.GetComponent <MoverData>().travel; float timeFactor = timeProjWillStayInAir / ts.time; Vector3 endPoint = new Vector3(); endPoint = ts.difference * timeFactor; positions[2] = targetPos - endPoint; return(positions); }
public static VRPSimultaneousPickupDelivery LoadDenthoffProblem(string path) { Tuple <DethloffType, int, int> dataName = ParseDethloffName(path); DethloffType type = dataName.Item1; int x = dataName.Item2; int y = dataName.Item3; StreamReader reader = new StreamReader(path); Fleet f = ParseFleetInfo(reader, x + 1); int clientAmount = int.Parse(reader.ReadLine().Trim()); TravelData m = ParseTravelMatrix(reader, clientAmount); ClientSet <PickupDeliveryClient> c = ParseClientInfo(reader, clientAmount); VRPSimultaneousPickupDelivery instance = new VRPSimultaneousPickupDelivery(c, f, m); instance.ProblemName = type.ToString() + x.ToString() + "-" + y.ToString(); return(instance); }
async void SearchGas_OnClick(object sender, EventArgs eventArgs) { if (_currentLocation == null) { _addressText.Text = "Location is null"; return; } Algorithm algorithm = new Algorithm(); GeoPoint currentLoc = new GeoPoint(_currentLocation.Latitude, _currentLocation.Longitude); GeoPoint destination = Algorithm.getFinalDestination(); TravelData currentRoute = await algorithm.getOriginalRoute("driving", currentLoc, destination); List <GeoPoint> pointsToSearch = algorithm.findPointsToSearch(currentRoute, 500, currentLoc); MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map); Android.Gms.Maps.GoogleMap map = mapFrag.Map; foreach (GeoPoint point in pointsToSearch) { MarkerOptions markerOpt1 = new MarkerOptions(); markerOpt1.SetPosition(new LatLng(point.latitude, point.longitude)); markerOpt1.SetTitle("Test Marker"); map.AddMarker(markerOpt1); CircleOptions circleOptions = new CircleOptions(); circleOptions.InvokeCenter(new LatLng(point.latitude, point.longitude)); circleOptions.InvokeRadius(500); map.AddCircle(circleOptions); } LatLng location2 = new LatLng(pointsToSearch[3].latitude, pointsToSearch[7].longitude); CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(location2); builder.Zoom(12); //builder.Bearing(155); //builder.Tilt(65); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); map.MoveCamera(cameraUpdate); }
async void drawRoute(TravelData route, bool isOriginalRoute) { MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map); Android.Gms.Maps.GoogleMap map = mapFrag.Map; // DRAW THE ORIGIN POINT FIRST, THEN POLYLINE, ENDPOINT, POLYLINE, ENDPOINT... PolylineOptions polylineOptions = new PolylineOptions(); polylineOptions.Add(new LatLng(route.steps [0].originXY.latitude, route.steps [0].originXY.longitude)); Polyline polyline = map.AddPolyline(polylineOptions); if (isOriginalRoute) { polyline.Color = Resources.GetColor(Resource.Color.wallet_holo_blue_light); } else { polyline.Color = Resources.GetColor(Resource.Color.abc_search_url_text_pressed); } polyline.Width = 15; polyLines.Add(polyline); foreach (Step step in route.steps) { polylineOptions = new PolylineOptions(); List <GeoPoint> stepPoints = Algorithm.decodePoints(step.polyLine); foreach (GeoPoint point in stepPoints) { polylineOptions.Add(new LatLng(point.latitude, point.longitude)); } polylineOptions.Add(new LatLng(step.endpointXY.latitude, step.endpointXY.longitude)); polyline = map.AddPolyline(polylineOptions); if (isOriginalRoute) { polyline.Color = Resources.GetColor(Resource.Color.wallet_holo_blue_light); } else { polyline.Color = Resources.GetColor(Resource.Color.abc_search_url_text_pressed); } polyline.Width = 15; polyLines.Add(polyline); } }
public static VRPSimultaneousPickupDelivery LoadSalhiNagyProblem(string path, int fleet, bool serieX) { //formato del fichero //clientes capacidad tiempo-maximo tiempo-ruptura //depot-x depot-y //para cada clietne //x y demand int id = ParseNagySalhiName(path); StreamReader reader = new StreamReader(path); string[] specification = reader.ReadLine().Split(' '); int clientAmount = int.Parse(specification[1]); int vehicleCapacity = int.Parse(specification[2]); string[] depot = reader.ReadLine().Split(' '); double xDepot = double.Parse(depot[1]); double yDepot = double.Parse(depot[2]); List <Tuple <double, double, double> > clientsInfo = new List <Tuple <double, double, double> >(clientAmount + 1); clientsInfo.Add(new Tuple <double, double, double>(xDepot, yDepot, 0)); while (!reader.EndOfStream) { string[] client = reader.ReadLine().Split(' '); if (client.Length == 4) { clientsInfo.Add(new Tuple <double, double, double>(double.Parse(client[1]), double.Parse(client[2]), double.Parse(client[3]))); } } TravelData matrix = BuildTravelCostMatrix(clientsInfo); ClientSet <PickupDeliveryClient> clientSet = BuildClientSet(clientsInfo, serieX); Fleet vehicles = Fleet.CreateHomogeneousFleet(fleet, vehicleCapacity); reader.Close(); VRPSimultaneousPickupDelivery problem = new VRPSimultaneousPickupDelivery(clientSet, vehicles, matrix); string serie = (serieX) ? "X" : "Y"; problem.ProblemName = string.Format("CMT{0}-{1}-{2}{3}", id, clientAmount, fleet, serie); return(problem); }
public static VRPSimultaneousPickupDelivery ParseSalhiNagyMixed(string path, int clientInterval, int[] fleet) { int id = ParseNagySalhiName(path); int fleetSize = fleet[id - 1]; StreamReader reader = new StreamReader(path); var sp = SalhiNagyProblemSpecification(reader); int clientAmount = sp.Item1; int vehicleCapacity = sp.Item2; List <Tuple <double, double, double> > clientsInfo = LoadClientInfo(reader, clientAmount); reader.Close(); TravelData matrix = BuildTravelCostMatrix(clientsInfo); ClientSet <PickupDeliveryClient> clientSet = BuildSalhiMixedClientSet(clientsInfo, clientInterval); Fleet vehicles = Fleet.CreateHomogeneousFleet(fleetSize, vehicleCapacity); VRPSimultaneousPickupDelivery problem = new VRPSimultaneousPickupDelivery(clientSet, vehicles, matrix); problem.ProblemName = string.Format("CMT{0}", id); return(problem); }
public void HandleMovement() { List<TravelData> dataList = CloneList(travelList); Parallel.ForEach(dataList, data => { double newdistance = data.distance - data.speed; if (newdistance <= 0) { // Ankunft im System: foreach (Ship ship in data.ship) { ship.Position = data.destination; } travelList.Remove(data); } else { TravelData neu = new TravelData(); neu.destination = data.destination; neu.fleet = data.fleet; neu.origin = data.origin; neu.route = data.route; neu.ship = data.ship; neu.speed = data.speed; neu.distance = newdistance; neu.timeRemaining = newdistance / data.speed; } }); main.log("Modul FlottenManagement: Schiffsbewegungen abgeschlossen"); }
public Squad(User owner, SquadSave save) { this.owner = owner; name = save.name; ident = save.ident; location = save.location; atStructure = save.atStructure; if (atStructure) { if (GameServer.Instance.Structures.OpExists(location)) { defendedStructure = GameServer.Instance.Structures.GetStructure(location); } else { atStructure = false; } } if (!atStructure && save.data != null) { data = new TravelData(save.data); } }
private void MapMarkerClick(object sender, GoogleMap.MarkerClickEventArgs markerClickEventArgs) { markerClickEventArgs.Handled = true; Marker marker = markerClickEventArgs.Marker; GeoPoint origin = Algorithm.getCurrentLocation(); GeoPoint endPoint = Algorithm.getFinalDestination(); GeoPoint pitStop = new GeoPoint(marker.Position.Latitude, marker.Position.Longitude); foreach (Polyline polyLine in polyLines) { polyLine.Remove(); } Algorithm algorithm = new Algorithm(); Task <TravelData> result = Task.Run(() => algorithm.getPitStopRoute("driving", origin, pitStop, endPoint)); TravelData pitStopRoute = result.Result; drawRoute(pitStopRoute, false); //drawRoute (originalRoute, true); //Toast.MakeText(this, "You clicked on Marker", ToastLength.Short).Show(); }
public override void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view) { Algorithm algorithm = new Algorithm(); CLLocationCoordinate2D origin = new CLLocationCoordinate2D(45.523538, -122.623040); CLLocationCoordinate2D endpoint = new CLLocationCoordinate2D(45.504796, -122.638593); GeoPoint originGeo = new GeoPoint(45.523538, -122.623040); GeoPoint endpointGeo = new GeoPoint(45.504796, -122.638593); var sampleAnnotation = view.Annotation as PitStopAnnotation; if (sampleAnnotation != null) { TravelData pitStopRouteData = algorithm.getPitStopRoute("driving", originGeo, new GeoPoint(sampleAnnotation.Coordinate.Latitude, sampleAnnotation.Coordinate.Longitude), endpointGeo); List <CLLocationCoordinate2D> pitStopCoordsList = new List <CLLocationCoordinate2D> (); for (int i = 0; i < pitStopRouteData.steps.Count; i++) { Step step = pitStopRouteData.steps [i]; pitStopCoordsList.Add(new CLLocationCoordinate2D(pitStopRouteData.steps [i].originXY.latitude, pitStopRouteData.steps [i].originXY.longitude)); List <GeoPoint> polylinePoints = Algorithm.decodePoints(step.polyLine); foreach (GeoPoint geoPoint in polylinePoints) { CLLocationCoordinate2D coord = new CLLocationCoordinate2D(geoPoint.latitude, geoPoint.longitude); pitStopCoordsList.Add(coord); } pitStopCoordsList.Add(new CLLocationCoordinate2D(pitStopRouteData.steps [i].endpointXY.latitude, pitStopRouteData.steps [i].endpointXY.longitude)); } CLLocationCoordinate2D[] coordsArray = pitStopCoordsList.ToArray(); mapView.RemoveOverlay(mapView.Overlays [0]); MKPolyline newOverlay = MKPolyline.FromCoordinates(coordsArray); mapView.AddOverlay(newOverlay); //demo accessing the title of the selected annotation Console.WriteLine("{0} was tapped", sampleAnnotation.Title); } }
/// <summary> /// Function to parse the contents of TravelData class /// </summary> /// <param name="FileName">The filename of the containing XML file</param> /// <param name="SectionElement">The XElement to parse</param> /// <param name="Data">Travel data to which the parse results apply</param> private static void ParseTravelDataNode(string FileName, XElement SectionElement, TravelData Data) { string Section = SectionElement.Name.LocalName; double Decelerate = 0.0; double Accelerate = 0.0; double TargetSpeed = 0.0; foreach (XElement KeyNode in SectionElement.Elements()) { string Key = KeyNode.Name.LocalName; string Value = KeyNode.Value; int LineNumber = ((IXmlLineInfo)KeyNode).LineNumber; switch (Key.ToLowerInvariant()) { case "decelerate": if (Value.Any() && !NumberFormats.TryParseDoubleVb6(Value, out Decelerate) || Decelerate < 0.0) { Interface.AddMessage(MessageType.Error, false, $"Value is expected to be a non-negative floating-point number in {Key} in {Section} at line {LineNumber.ToString(culture)} in {FileName}"); } break; case "position": case "stopposition": if (Value.Any() && !NumberFormats.TryParseDoubleVb6(Value, out Data.Position)) { Interface.AddMessage(MessageType.Error, false, $"Value is invalid in {Key} in {Section} at line {LineNumber.ToString(culture)} in {FileName}"); } break; case "accelerate": if (Value.Any() && !NumberFormats.TryParseDoubleVb6(Value, out Accelerate) || Accelerate < 0.0) { Interface.AddMessage(MessageType.Error, false, $"Value is expected to be a non-negative floating-point number in {Key} in {Section} at line {LineNumber.ToString(culture)} in {FileName}"); } break; case "targetspeed": if (Value.Any() && !NumberFormats.TryParseDoubleVb6(Value, out TargetSpeed) || TargetSpeed < 0.0) { Interface.AddMessage(MessageType.Error, false, $"Value is expected to be a non-negative floating-point number in {Key} in {Section} at line {LineNumber.ToString(culture)} in {FileName}"); } break; case "rail": if (Value.Any() && !NumberFormats.TryParseIntVb6(Value, out Data.RailIndex) || Data.RailIndex < 0) { Interface.AddMessage(MessageType.Error, false, $"Value is expected to be a non-negative integer number in {Key} in {Section} at line {LineNumber.ToString(culture)} in {FileName}"); Data.RailIndex = 0; } break; } } Data.Decelerate = -Decelerate / 3.6; Data.Accelerate = Accelerate / 3.6; Data.TargetSpeed = TargetSpeed / 3.6; }
private String GetRouteLabel(TravelData travelData) { return(allStops.Find(s => s.Name == travelData.TravelFrom).Route.Label); }
public int CalculateTotalPrice(TravelData travelData, int travelTime) { return(Calculate.TotalPrice( travelData.TravelFrom, travelData.Travellers, travelTime, allStops, allRoutes, allTicketTypes, PriceRounding)); }
private List <String> CalculateTravelTimeStamps(TravelData travelData) { return(Calculate.TravelTimeStamps(travelData.TravelFrom, travelData.TravelTo, allStops, allRouteTables)); }
public int CalculateTravelTime(TravelData travelData) { return(Calculate.TravelTime(travelData.TravelFrom, travelData.TravelTo, allStops)); }
/// <summary> /// Basic auto gas price from origin zone to destination zone /// </summary> /// <param name="origin"></param> /// <param name="destination"></param> /// <param name="time"></param> /// <returns></returns> public float Cost(IZone origin, IZone destination, Time time) { return(TravelData.TravelCost(origin, destination, time)); }
/// <summary> /// This gets the travel time between zones /// </summary> /// <param name="origin">Where to start</param> /// <param name="destination">Where to go</param> /// <param name="time">What time of day is it? (hhmm.ss)</param> /// <returns>The amount of time it will take</returns> public Time TravelTime(IZone origin, IZone destination, Time time) { return(TravelData.TravelTime(origin, destination, time)); }
public virtual void Deploy(Vector2Int start, Vector2Int finish) { data = new TravelData(start, finish); }
public override void Initialize(System.IO.BinaryReader reader, RecordHeader header) { while (reader.BaseStream.Position < header.DataEndPos) { var type = (SubRecordType)reader.ReadInt32(); var size = reader.ReadInt32(); switch (type) { case SubRecordType.Id: name = reader.ReadString(size); break; case SubRecordType.Model: model = reader.ReadString(size); break; case SubRecordType.Name: fullName = reader.ReadString(size); break; case SubRecordType.RaceName: race = Record.GetRecord <Race>(reader.ReadString(size)); break; // Npc's have this even if they are part of no faction, so it needs to be checked if empty first case SubRecordType.Anam: string fac = reader.ReadString(size); faction = string.IsNullOrEmpty(fac) ? null : faction = Record.GetRecord <Faction>(fac); break; case SubRecordType.BodyName: head = BodyPartRecord.Get(reader.ReadString(size)); break; case SubRecordType.CreatureName: classId = Record.GetRecord <ClassRecord>(reader.ReadString(size)); break; case SubRecordType.KeyName: hair = BodyPartRecord.Get(reader.ReadString(size)); break; case SubRecordType.NpcData: npcData = new NpcRecordData(reader, size); break; case SubRecordType.Flag: npcFlags = (NpcFlags)reader.ReadInt32(); break; case SubRecordType.InventoryItem: items.Add(new InventoryItem(reader)); break; case SubRecordType.NpcSpell: spells.Add(Record.GetRecord <SpellRecord>(reader.ReadString(size))); break; case SubRecordType.AiData: aiData = new AiData(reader); break; case SubRecordType.AiWanderData: wanderData = new WanderData(reader); break; case SubRecordType.AiTravelData: travelData = new TravelData(reader); break; case SubRecordType.AiFollowData: followData = new FollowData(reader); break; case SubRecordType.AiEscortData: escortData = new EscortData(reader); break; case SubRecordType.ContainerData: cellEscortFollow = reader.ReadString(size); break; case SubRecordType.AiActivateData: activateData = new ActivateData(reader); break; case SubRecordType.DoorData: destinationData.Add(DoorExitData.Create(reader)); break; case SubRecordType.DoorName: destinations.Add(reader.ReadString(size)); break; case SubRecordType.Scale: scale = reader.ReadSingle(); break; case SubRecordType.Script: script = Script.Get(reader.ReadString(size)); break; } } }
public static void RefreshTravelDestinationsPost(MerchantFastTravel __instance, bool _forceRefresh) { try { List <TravelData> tmpCurrentTravelData = (List <TravelData>)AccessTools.Field(typeof(MerchantFastTravel), "tmpCurrentTravelData").GetValue(__instance); List <int> m_travelToRegion = (List <int>)AccessTools.Field(typeof(MerchantFastTravel), "m_travelToRegion").GetValue(__instance); bool InCity = (bool)AccessTools.Property(typeof(MerchantFastTravel), "InCity").GetValue(__instance); AreaManager.AreaEnum m_currentAreaAssociatedCity = (AreaManager.AreaEnum)AccessTools.Field(typeof(MerchantFastTravel), "m_currentAreaAssociatedCity").GetValue(__instance); MethodInfo InCierzoArea = AccessTools.Method(typeof(MerchantFastTravel), "InCierzoArea"); MethodInfo InBergArea = AccessTools.Method(typeof(MerchantFastTravel), "InBergArea"); MethodInfo InLevantArea = AccessTools.Method(typeof(MerchantFastTravel), "InLevantArea"); MethodInfo InMonsoonArea = AccessTools.Method(typeof(MerchantFastTravel), "InMonsoonArea"); MethodInfo InHarmattanArea = AccessTools.Method(typeof(MerchantFastTravel), "InHarmattanArea"); MethodInfo CheckIfLevantBlocked = AccessTools.Method(typeof(MerchantFastTravel), "CheckIfLevantBlocked"); MethodInfo InNewSiroccoArea = AccessTools.Method(typeof(MerchantFastTravel), "InNewSiroccoArea"); tmpCurrentTravelData.Clear(); if (PhotonNetwork.isNonMasterClientInRoom && !_forceRefresh) { return; } Global.RPCManager.RequestMerchantFastTravelDestinations(); m_travelToRegion.Clear(); Area currentArea = AreaManager.Instance.CurrentArea; InCity = AreaManager.Instance.GetIsAreaTownOrCity(currentArea); if ((bool)InCierzoArea.Invoke(__instance, new object[] { currentArea })) { m_currentAreaAssociatedCity = AreaManager.AreaEnum.CierzoVillage; } else if ((bool)InBergArea.Invoke(__instance, new object[] { currentArea })) { m_currentAreaAssociatedCity = AreaManager.AreaEnum.Berg; } else if ((bool)InLevantArea.Invoke(__instance, new object[] { currentArea })) { m_currentAreaAssociatedCity = AreaManager.AreaEnum.Levant; } else if ((bool)InMonsoonArea.Invoke(__instance, new object[] { currentArea })) { m_currentAreaAssociatedCity = AreaManager.AreaEnum.Monsoon; } else if ((bool)InHarmattanArea.Invoke(__instance, new object[] { currentArea })) { m_currentAreaAssociatedCity = AreaManager.AreaEnum.Harmattan; } else if ((bool)InNewSiroccoArea.Invoke(__instance, new object[] { currentArea })) { m_currentAreaAssociatedCity = AreaManager.AreaEnum.NewSirocco; } else { m_currentAreaAssociatedCity = AreaManager.AreaEnum.Tutorial; } CanTravelToHarmattan = (StoreManager.Instance.IsDlcInstalled(OTWStoreAPI.DLCs.Soroboreans) && !(bool)InHarmattanArea.Invoke(__instance, new object[] { currentArea })); if (!InCity || (bool)InHarmattanArea.Invoke(__instance, new object[] { currentArea })) { if (!QuestEventManager.Instance.HasQuestEvent("lDHL_XMS7kKEs0uOqrLQjw") && !(bool)InCierzoArea.Invoke(__instance, new object[] { currentArea })) { m_travelToRegion.Add(100); } if (!QuestEventManager.Instance.HasQuestEvent("vW4sarzBGkalTwy_KhGI6A") && !(bool)InBergArea.Invoke(__instance, new object[] { currentArea })) { m_travelToRegion.Add(500); } if ((bool)CheckIfLevantBlocked.Invoke(__instance, null) && !(bool)InLevantArea.Invoke(__instance, new object[] { currentArea })) { m_travelToRegion.Add(300); } if (!(bool)InMonsoonArea.Invoke(__instance, new object[] { currentArea })) { m_travelToRegion.Add(200); } if (!(bool)InHarmattanArea.Invoke(__instance, new object[] { currentArea })) { m_travelToRegion.Add(400); } if (StoreManager.Instance.IsDlcInstalled(OTWStoreAPI.DLCs.DLC2) && !(bool)InNewSiroccoArea.Invoke(__instance, new object[] { currentArea }) && QuestEventManager.Instance.HasQuestEvent("eYmZGb_BJ0qAtpcwrndhTg")) { m_travelToRegion.Add(601); } } else if (CanTravelToHarmattan) { m_travelToRegion.Add(400); } foreach (int regionId in m_travelToRegion) { TravelData merchantTravelData = AreaManager.Instance.GetMerchantTravelData(m_currentAreaAssociatedCity, (AreaManager.AreaEnum)regionId); if (merchantTravelData != null) { tmpCurrentTravelData.Add(merchantTravelData); } } SyncTravelDestinations(); } catch (Exception ex) { SoroboreansDlcTravelUnleashed.Instance.MyLogger.LogError(ex.Message); } }
public void travel(List<Ship> ships, Route route) { int fleet = findFreeFleet(); Solarsystem start = route.start; Solarsystem end = route.end; List<TravelData> fleetData = new List<TravelData>(); double speed = double.MaxValue; foreach (Ship ship in ships) { if (ship.speed < speed) { speed = ship.speed; } } TravelData neu = new TravelData(); neu.destination = end; neu.fleet = fleet; neu.origin = start; neu.route = route; neu.speed = speed; neu.ship = ships; neu.distance = route.distance; neu.timeRemaining = route.distance / speed; travelList.Add(neu); }