private static void UpdateHUD(TrainCar trainCar, ExtraBrakeState state) { if (CarTypes.IsAnyLocomotiveOrTender(trainCar.carType)) { HeadsUpDisplayBridge.instance?.UpdateEqualizingReservoirPressure(trainCar, state.equalizingReservoirPressure); } else { HeadsUpDisplayBridge.instance?.UpdateAuxReservoirPressure(trainCar, state.auxReservoirPressure); } HeadsUpDisplayBridge.instance?.UpdateBrakeCylinderPressure(trainCar, state.cylinderPressure); }
public static void Main(string[] args) { ParkingFactory parkingFactory = new ParkingFactory(); Cars cars = null; CarTypes CurrentCar = CarTypes.Hatchback; while ((CurrentCar = EnteredCar()) != CarTypes.Closed) { cars = parkingFactory.CurrentCarObject(CurrentCar); cars.welcome(); } }
public async Task <ActionResult> Create([Bind(Include = "Id,Name")] CarTypes carTypes) { if (ModelState.IsValid) { db.CarTypes.Add(carTypes); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(carTypes)); }
public ActionResult DeleteCarType(int?id) { using (CarStoreEntities db = new CarStoreEntities()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CarTypes cartype = db.CarTypes.Find(id); return(View(cartype)); } }
/// <summary> /// Add car on parking WITHOUT starting balance. /// </summary> /// <param name="carType">Type of car</param> public void AddCar(CarTypes carType) { try { Parking.AddCar(carType); Console.WriteLine("Done!"); } catch (NoFreeParkingPlacesException) { Console.WriteLine("No free parking places!"); } }
public static void ExportLocoControllerCurves(CommandArg[] args) { if (Terminal.IssuedError) { return; } string name = args[0].String; if (Enum.TryParse(name, out TrainCarType carType)) { GameObject prefab = CarTypes.GetCarPrefab(carType); if (!prefab) { Debug.LogError($"CarType {name} has missing prefab"); return; } LocoControllerBase locoController = prefab.GetComponent <LocoControllerBase>(); if (!locoController) { Debug.LogWarning($"CarType {name} prefab does not have a loco controller"); return; } var props = new JObject(); // brake & traction JObject brakeCurve = ComponentsToJson.AnimationCurve(locoController.brakePowerCurve); props.Add("brakePowerCurve", brakeCurve); if (locoController is LocoControllerDiesel lcd) { var tractionCurve = ComponentsToJson.AnimationCurve(lcd.tractionTorqueCurve); props.Add("tractionTorqueCurve", tractionCurve); } else if (locoController is LocoControllerSteam lcs) { var tractionCurve = ComponentsToJson.AnimationCurve(lcs.tractionTorqueCurve); props.Add("tractionTorqueCurve", tractionCurve); } else if (locoController is LocoControllerShunter lcShunt) { var tractionCurve = ComponentsToJson.AnimationCurve(lcShunt.tractionTorqueCurve); props.Add("tractionTorqueCurve", tractionCurve); } // driving force props.Add("drivingForce", ComponentsToJson.DrivingForce(locoController.drivingForce)); GameObjectDumper.SendJsonToFile(name, "loco_curves", props); } }
static void Main(string[] args) { List <Car> cars = new List <Car>(); bool run = true; while (run) { Write("Was möchten sie machen?(1 = Auto eingeben, 2 = zeig alle Autos, 3 = Beenden )"); int select = ReadInt(); if (select == 2) { foreach (Car oneCar in cars) { Console.WriteLine(oneCar.ToString()); } break; } if (select == 3) { run = false; break; } Write("Welchen Autotyp wünschen Sie?(1 = Sportauto, 2 = Standardauto)Bitte Zahl eingeben:"); int type = ReadInt(); CarTypes carType = CarTypes.Normalcar; if (type == 1) { carType = CarTypes.Sportcar; } Write("Welchen Name hat das Auto?"); string carName = Read(); Write("Welchen Hersteller hat das Auto?"); string carBrand = Read(); Write("Welches Baujahr hat das Auto?"); int carConstructionYear = ReadInt(); Write("Welche Farbe hat das Auto?"); string carColor = Read(); Write($"Ihr Auto: {carType} {carName} {carBrand} {carConstructionYear} {carColor}"); if (type == 1) { Sportcar sportcar = new Sportcar(carName, carBrand, carConstructionYear, carColor); cars.Add(sportcar); } else if (type == 2) { Car car = new Car(carName, carBrand, carConstructionYear, carColor); cars.Add(car); } } Console.ReadKey(); }
public ActionResult EditCarType([Bind(Include = "Name,CarTypesId,Description,Type")] CarTypes cartype) { if (ModelState.IsValid) { using (CarStoreEntities db = new CarStoreEntities()) { db.Entry(cartype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("CarTypeList", "Admin")); } } return(View(cartype)); }
private static void RestoreShunterDefaults(TrainCar trainCar) { var prefab = CarTypes.GetCarPrefab(TrainCarType.LocoShunter).GetComponent <TrainCar>().interiorPrefab.transform; var gaugeMat = prefab.Find("C dashboard buttons controller/I gauges backlights/lamp emmision indicator/gauge_stickers model").GetComponent <MeshRenderer>().material; gaugeMat.SetColor("_EmissionColor", trainCar.interior.GetComponentInChildren <ShunterDashboardControls>().cabLightRotary.GetComponent <ControlImplBase>().Value > 0 ? Color.white : Color.black); // set gauges material trainCar.interior.Find($"loco_621_interior(Clone)/C dashboard buttons controller/I gauges backlights/lamp emmision indicator/gauge_stickers model") .GetComponent <MeshRenderer>().material = gaugeMat; // set needles material SHUNTER_NEEDLE_TRANSFORMS.ToList().ForEach(t => trainCar.interior.Find($"loco_621_interior(Clone)/{t}").GetComponent <MeshRenderer>().material = gaugeMat); }
public ActionResult AddCarType(CarTypes cartype) { if (ModelState.IsValid) { using (CarStoreEntities db = new CarStoreEntities()) { db.CarTypes.Add(cartype); db.SaveChanges(); return(RedirectToAction("CarTypeList", "Admin")); } } return(View()); }
public void CarDetails(string carName, CarTypes typeName, int seatCapcity) { OfferRide = new OfferRide(); Car car = new Car { Name = carName, TypeName = typeName, SeatCapacity = seatCapcity, }; Cars.Add(car); OfferRide.Car = car; OfferRide.AvailableSeats = seatCapcity; }
private static void AddCar() // Adding car to parking { CarTypes carType = CarTypeChoseMenu(); Console.Clear(); Console.WriteLine($"Car type: {carType}"); try { Console.Write("Enter Car`s ID: "); String ID = Console.ReadLine(); if (string.IsNullOrWhiteSpace(ID)) { throw new ArgumentException("Invalid ID"); } Console.Write("Enter start balance: "); decimal balance = decimal.Parse(Console.ReadLine()); if (balance < 0) { throw new ArgumentException("Invalid balance, enter positive or zero balance"); } Parking.AddCar(new Car(ID, carType, balance)); Console.WriteLine("Car Added"); } catch (FormatException ex) { Console.Clear(); Console.WriteLine("Invalid balance format"); } catch (ArgumentNullException ex) { Console.Clear(); Console.WriteLine("Balance not entered"); } catch (ArgumentException ex) { Console.Clear(); Console.WriteLine(ex.Message); } catch (Exception ex) { Console.Clear(); Console.WriteLine("Invalid data"); } Console.ReadKey(); MainMenu(); }
public ICar OrderCar(CarTypes type) { Logger.Write($"Order placed for {type} car."); var car = CreateCar(type); car.PerformValet(); car.PerformService(); car.AddFuel(); Logger.Write($"Order completed with car: {car.ToString()}"); return(car); }
// GET: Guides/CarTypes/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CarTypes carTypes = await db.CarTypes.FindAsync(id); if (carTypes == null) { return(HttpNotFound()); } return(View(carTypes)); }
public static void Postfix(JObject carData, TrainCar __result) { if (carData.TryGetValue(SaveKey, out JToken token) && token is JObject obj) { var serializer = new JsonSerializer(); var state = ExtraBrakeState.Instance(__result.brakeSystem); serializer.Populate(new JTokenReader(token), state); if (CarTypes.IsLocomotive(__result.carType) && obj.TryGetValue(mainReservoirKey, out var mainResPressure)) { __result.brakeSystem.mainReservoirPressure = __result.brakeSystem.mainReservoirPressureUnsmoothed = mainResPressure.Value <float>(); } Main.DebugLog($"Loaded state for {carData["id"]}: {state}"); } }
public ActionResult DeleteCarType(int id) { using (CarStoreEntities db = new CarStoreEntities()) { CarTypes cartype = db.CarTypes.Find(id); if (ModelState.IsValid) { db.CarTypes.Remove(cartype); db.SaveChanges(); return(RedirectToAction("CarTypeList", "Admin")); } return(View()); } }
private void SetCarToSpawn(CustomCar car) { carPrefabToSpawn = CarTypes.GetCarPrefab(car.TrainCarType); if (carPrefabToSpawn == null) { Debug.LogError( $"Couldn't load car prefab: {car.TrainCarType}! Won't be able to spawn this car.", this); } else { //var component = carPrefabToSpawn.GetComponent<TrainCar>(); carBounds = car.Bounds; display.SetContent(car.identifier + "\n" + car.InterCouplerDistance.ToString("F") + "m"); } }
public static void Register(TrainCarType carType) { Registry.Register(carType, tractiveEffortProvider); Registry.Register(carType, adhesionProvider); Registry.Register(carType, new QueryDataProvider( "Slip", () => Main.settings.ShowSlip, car => car.GetComponent <DrivingForce>().wheelslip * 100, f => $"{f.ToString("F1")} %")); if (CarTypes.IsSteamLocomotive(carType)) { SteamLocoProviders.Register(carType); } }
public static void ExportDamageProperties(CommandArg[] args) { if (Terminal.IssuedError) { return; } string name = args[0].String; if (Enum.TryParse(name, out TrainCarType carType)) { GameObject prefab = CarTypes.GetCarPrefab(carType); if (!prefab) { Debug.LogError($"CarType {name} has missing prefab"); return; } var damage = prefab.GetComponent <DamageController>(); if (!damage) { Debug.LogWarning($"CarType {name} prefab does not have a damage controller"); return; } var ctrlProps = new JObject { { "wheelsHP", damage.wheels.fullHitPoints }, { "speedToBrakeDamageCurve", ComponentsToJson.AnimationCurve(damage.speedToBrakeDamageCurve) }, }; if (damage is DamageControllerDiesel dcd) { ctrlProps.Add("engineHP", dcd.engine.fullHitPoints); } else if (damage is DamageControllerShunter dcs) { ctrlProps.Add("engineHP", dcs.engine.fullHitPoints); } if (TrainCarAndCargoDamageProperties.carDamageProperties.TryGetValue(carType, out CarDamageProperties dmgProps)) { ctrlProps.Add("bodyDamage", ComponentsToJson.CarDamageProperties(dmgProps)); } GameObjectDumper.SendJsonToFile(name, "damage", ctrlProps); } }
private static void Postfix(TrainCar trainCar, ref bool __result) { if (NetworkManager.IsClient()) { if (!SingletonBehaviour <NetworkTrainManager> .Exists) { return; } if (!NetworkManager.IsHost()) { __result = false; } else if (NetworkManager.IsHost()) { bool isPlayerNotNearTrain = true; float distCheck; if (CarTypes.IsAnyLocomotiveOrTender(trainCar.carType)) { distCheck = 16000000f; } else if (!trainCar.playerSpawnedCar) { distCheck = 360000f; } else { distCheck = 9000000f; } foreach (GameObject player in SingletonBehaviour <NetworkPlayerManager> .Instance.GetPlayers()) { isPlayerNotNearTrain = (trainCar.transform.position - player.transform.position).sqrMagnitude > distCheck; if (!isPlayerNotNearTrain) { break; } } if (isPlayerNotNearTrain) { isPlayerNotNearTrain = (trainCar.transform.position - PlayerManager.PlayerTransform.position).sqrMagnitude > distCheck; } __result = isPlayerNotNearTrain; } } }
public ActionResult DetailsCarType(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (CarStoreEntities db = new CarStoreEntities()) { CarTypes cartype = db.CarTypes.Find(id); if (cartype == null) { return(HttpNotFound()); } return(View(cartype)); } }
private void GetCarTypesDetails(XmlDocument doc) { carTypes = new List <CarTypes>(); for (var i = 0; i < doc.DocumentElement.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes.Count; i++) { CarTypes ct = new CarTypes() { TypicalSeating = doc.DocumentElement.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[i].ChildNodes[0].InnerText, //city CarTypeName = doc.DocumentElement.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[i].ChildNodes[1].InnerText, //id CarTypeCode = doc.DocumentElement.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[i].ChildNodes[2].InnerText, //Name PossibleFeatures = doc.DocumentElement.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[i].ChildNodes[3].InnerText, PossibleModels = doc.DocumentElement.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[i].ChildNodes[4].InnerText //state }; carTypes.Add(ct); } }
public static void OnCarSpawned(TrainCar car) { if (CarTypes.IsAnyLocomotiveOrTender(car.carType)) { return; } if (car.GetComponent <CabooseController>() == null) { var cabooseController = car.gameObject.AddComponent <CabooseController>(); cabooseController.cabTeleportDestinationCollidersGO = new GameObject(); } if (UnityModManager.FindMod("AirBrake")?.Enabled ?? false) { car.StartCoroutine(DelayedSetIndependent(car)); } }
/// <summary> /// Add car on parking WITH starting balance. /// </summary> /// <param name="carType">Type of car</param> /// <param name="defaultBalance">Starting balance of car</param> /// <param name="carType">Type of car</param> public void AddCar(CarTypes carType, double defaultBalance) { try { Parking.AddCar(carType, defaultBalance); //Console.WriteLine("Done!"); } catch (NoFreeParkingPlacesException) { //Console.WriteLine("No free parking places!"); } catch (CarBalanceLessZeroException) { //Console.WriteLine("Starting balance of car cannot be less zero!"); } }
public static void ExportCabControls(CommandArg[] args) { if (Terminal.IssuedError) { return; } string name = args[0].String; if (Enum.TryParse(name, out TrainCarType carType)) { GameObject prefab = CarTypes.GetCarPrefab(carType); if (!prefab) { Debug.LogError($"CarType {name} has missing prefab"); return; } TrainCar car = prefab.GetComponent <TrainCar>(); if (!car) { Debug.LogError($"Couldn't find TrainCar on carType {name}"); return; } if (!car.interiorPrefab) { Debug.LogWarning($"TrainCar on carType {name} doesn't have an interiorPrefab assigned"); return; } var specList = new JArray(); var controlSpecs = car.interiorPrefab.GetComponentsInChildren <ControlSpec>(); foreach (ControlSpec spec in controlSpecs) { specList.Add(ComponentsToJson.GenericObject(spec)); } var indicators = car.interiorPrefab.GetComponentsInChildren <Indicator>(); foreach (Indicator ind in indicators) { specList.Add(ComponentsToJson.GenericObject(ind)); } GameObjectDumper.SendJsonToFile(name, "control_spec", specList); } }
//=========== READING ============ #region Reading /**<summary>Reads the object header.</summary>*/ internal override void Read(BinaryReader reader) { long startPosition = reader.BaseStream.Position; Reserved0x00 = reader.ReadUInt64(); Flags = (AttractionFlags)reader.ReadUInt32(); for (int i = 0; i < 3; i++) { TrackTypeList[i] = (TrackTypes)reader.ReadByte(); } MinCarsPerTrain = reader.ReadByte(); MaxCarsPerTrain = reader.ReadByte(); CarsPerFlatRide = reader.ReadByte(); ZeroCars = reader.ReadByte(); CarTabIndex = reader.ReadByte(); DefaultCarType = (CarTypes)reader.ReadByte(); FrontCarType = (CarTypes)reader.ReadByte(); SecondCarType = (CarTypes)reader.ReadByte(); RearCarType = (CarTypes)reader.ReadByte(); ThirdCarType = (CarTypes)reader.ReadByte(); Padding0x19 = reader.ReadByte(); for (int i = 0; i < 4; i++) { CarTypeList[i].Read(reader); } reader.BaseStream.Position = startPosition + 0x1B2; Excitement = reader.ReadByte(); Intensity = reader.ReadByte(); Nausea = reader.ReadByte(); MaxHeight = reader.ReadByte(); AvailableTrackSections = (TrackSections)reader.ReadUInt64(); RideCategory = (RideCategories)reader.ReadByte(); RideCategoryAlternate = (RideCategories)reader.ReadByte(); SoldItem1 = (ItemTypes)reader.ReadByte(); SoldItem2 = (ItemTypes)reader.ReadByte(); }
private void PointToCar(TrainCar?car) { if (PointedCar != car) { if ((car != null) && CarTypes.IsLocomotive(car.carType)) { PointedCar = car; HighlightCar(PointedCar, selectionMaterial !); CommsRadioController.PlayAudioFromRadio(HoverCarSound, transform); } else { PointedCar = null; ClearHighlightedCar(); } } }
//=========== READING ============ #region Reading /** <summary> Reads the object header. </summary> */ internal override void Read(BinaryReader reader) { long startPosition = reader.BaseStream.Position; this.Reserved0x00 = reader.ReadUInt64(); this.Flags = (AttractionFlags)reader.ReadUInt32(); for (int i = 0; i < 3; i++) { this.TrackTypeList[i] = (TrackTypes)reader.ReadByte(); } this.MinCarsPerTrain = reader.ReadByte(); this.MaxCarsPerTrain = reader.ReadByte(); this.CarsPerFlatRide = reader.ReadByte(); this.ZeroCars = reader.ReadByte(); this.CarTabIndex = reader.ReadByte(); this.DefaultCarType = (CarTypes)reader.ReadByte(); this.FrontCarType = (CarTypes)reader.ReadByte(); this.SecondCarType = (CarTypes)reader.ReadByte(); this.RearCarType = (CarTypes)reader.ReadByte(); this.ThirdCarType = (CarTypes)reader.ReadByte(); this.Padding0x19 = reader.ReadByte(); for (int i = 0; i < 4; i++) { this.CarTypeList[i].Read(reader); } reader.BaseStream.Position = startPosition + 0x1B2; this.Excitement = reader.ReadByte(); this.Intensity = reader.ReadByte(); this.Nausea = reader.ReadByte(); this.MaxHeight = reader.ReadByte(); this.AvailableTrackSections = (TrackSections)reader.ReadUInt64(); this.RideType = (RideTypes)reader.ReadByte(); this.RideTypeAlternate = (RideTypes)reader.ReadByte(); this.SoldItem1 = (ItemTypes)reader.ReadByte(); this.SoldItem2 = (ItemTypes)reader.ReadByte(); }
public static void ExportCarColliders(CommandArg[] args) { if (Terminal.IssuedError) { return; } string name = args[0].String; if (Enum.TryParse(name, out TrainCarType carType)) { GameObject prefab = CarTypes.GetCarPrefab(carType); if (!prefab) { Debug.LogError($"CarType {name} has missing prefab"); return; } Transform colliderRoot = prefab.transform.Find("[colliders]"); if (!colliderRoot) { Debug.LogWarning($"CarType {name} does not have a colliders root transform"); return; } var colliderDict = new JObject(); foreach (string categoryName in colliderCategories) { Transform subTransform = colliderRoot.Find(categoryName); if (subTransform) { Collider[] colliders = subTransform.gameObject.GetComponentsInChildren <Collider>(); var colliderCategory = ComponentsToJson.Colliders(colliders); colliderDict.Add(new JProperty(categoryName, colliderCategory)); } } GameObjectDumper.SendJsonToFile(name, "colliders", colliderDict); } else { Debug.LogWarning("Invalid car type " + name); } }
/// <summary> /// Instance of Car class WITH starting Balance (Balance property) /// </summary> /// <param name="carType">Type of Car</param> /// <param name="numberOfParkingPlace">Number of parking place</param> /// <param name="defaultBalance">Starting parking balance of car</param> public Car(CarTypes carType, int numberOfParkingPlace, double defaultBalance) { SetIdOfCar(); CarType = carType; NumberOfParkingPlace = numberOfParkingPlace; if (defaultBalance < 0) { throw new CarBalanceLessZeroException("Starting balance less than zero!"); } else { Balance = defaultBalance; } }
public Car CreateCar(string carDescription, double carFuelEconomy, string carPictureUrl, ICollection<int> carFeaturesIds, CarTypes carCarType) { var carToAdd = new Car { Description = carDescription, FuelEconomy = carFuelEconomy, PictureUrl = carPictureUrl, CarType = carCarType }; //this.cars.Add(carToAdd); //this.cars.SaveChanges(); foreach (var featureId in carFeaturesIds) { var feature = this.features.GetById(featureId); feature.Cars.Add(carToAdd); } this.features.SaveChanges(); return carToAdd; }