public static void addCar(CarEntity carEntity) { using (ITransaction transaction = session.BeginTransaction()) { PersonaEntity personaEntity = session.Load<PersonaEntity>(Access.CurrentSession.ActivePersona.Id); personaEntity.addCar(carEntity); session.SaveOrUpdate(personaEntity); transaction.Commit(); Access.CurrentSession.ActivePersona.Cars.Add(new Car(carEntity)); } }
public static CustomCar getCustomCar(CarEntity carEntity) { CustomCar customCar = new CustomCar(); customCar.baseCarId = carEntity.baseCarId; customCar.carClassHash = (Int32)carEntity.raceClass; customCar.id = carEntity.id; customCar.isPreset = false; customCar.level = 0; customCar.name = null; customCar.paints = carEntity.paints; customCar.performanceParts = carEntity.performanceParts; customCar.physicsProfileHash = carEntity.physicsProfileHash; customCar.rating = carEntity.rating; customCar.resalePrice = carEntity.resalePrice; customCar.skillModParts = carEntity.skillModParts; customCar.skillModSlotCount = 6; customCar.vinyls = carEntity.vinyls; customCar.visualParts = carEntity.visualParts; return customCar; }
public virtual void addCar(CarEntity car) { car.ownerPersona = this; garage.Add(car); }
public virtual void removeCar(CarEntity car) { garage.Remove(car); }
public Car(CarEntity car) { Id = car.id; BaseCarId = car.baseCarId; RaceClass = car.raceClass; Paints = XElement.Parse(car.paints); PerformanceParts = XElement.Parse(car.performanceParts); PhysicsProfileHash = car.physicsProfileHash; Rating = car.rating; ResalePrice = car.resalePrice; SkillModParts = XElement.Parse(car.skillModParts); Vinyls = XElement.Parse(car.vinyls); VisualParts = XElement.Parse(car.visualParts); Durability = car.durability; ExpirationDate = car.expirationDate; HeatLevel = car.heatLevel; CarId = car.carId; PersonaId = car.ownerPersona.id; }
private void vCreateDb() { if (!DataEx.db_ServerExists) { log.Warn("Database doesn't exist!"); if (!Directory.Exists(DataEx.dir_Database)) Directory.CreateDirectory(DataEx.dir_Database); log.Info("Creating database."); ISessionFactory sessionFactory = SessionManager.createDatabase(); log.Info("Setting minimum pkPersonaId to 100."); using (var sqliteConnection = new SQLiteConnection("Data Source=\"" + DataEx.db_Server + "\";Version=3;")) { sqliteConnection.Open(); SQLiteCommand insertSQL = new SQLiteCommand("INSERT INTO sqlite_sequence (name, seq) VALUES ('Personas', 99)", sqliteConnection); insertSQL.ExecuteNonQuery(); sqliteConnection.Close(); } log.Info("Inserting filler entries."); using (var session = sessionFactory.OpenSession()) using (var transaction = session.BeginTransaction()) { UserEntity userEntity = new UserEntity(); userEntity.defaultPersonaIdx = 0; for (int i = 0; i < 20; i++) { PersonaEntity personaEntity = new PersonaEntity(); personaEntity.boost = 7331; personaEntity.cash = 1337; personaEntity.currentCarIndex = 0; personaEntity.iconIndex = 27; personaEntity.level = 60; personaEntity.motto = "test"; personaEntity.name = "DEBUG Id" + (i + 100); personaEntity.percentageOfLevelCompletion = 100; personaEntity.rating = 8752; personaEntity.reputationInLevel = 0; personaEntity.reputationInTotal = 99999999; personaEntity.score = 2578; CarEntity carEntity = new CarEntity(); carEntity.baseCarId = 1816139026L; carEntity.durability = 100; carEntity.heatLevel = 6; carEntity.carId = 1; carEntity.paints = "<Paints/>"; carEntity.performanceParts = "<PerformanceParts/>"; carEntity.physicsProfileHash = 4123572107L; carEntity.raceClass = CarClass.A; carEntity.rating = 750; carEntity.resalePrice = 123456789; carEntity.skillModParts = "<SkillModParts/>"; carEntity.vinyls = "<Vinyls/>"; carEntity.visualParts = "<VisualParts/>"; personaEntity.addCar(carEntity); session.Save(personaEntity); } session.Save(userEntity); transaction.Commit(); log.Info("Database actions finalized."); } } else { log.Info("Database already exists, skipping creation."); } }
private void SetupComponents() { #region FlipViewPersona FlipViewPersonaImage.HideControlButtons(); Grid[] aFlipViewAvatarArray = new Grid[28]; for (int i = 0; i < 28; i++) { Grid Grid_FlipViewDummy; Image Image_FlipViewDummy; Image_FlipViewDummy = new Image() { Margin = new Thickness(5.5d), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Stretch = Stretch.Uniform, Source = (ImageSource)BitmapFrame.Create(new Uri("pack://application:,,,/OfflineServer;component/images/NFSW_Avatars/Avatar_" + i.ToString() + ".png", UriKind.Absolute)) }; Grid_FlipViewDummy = new Grid() { Margin = new Thickness(0.4d) }; Grid_FlipViewDummy.Children.Add(Image_FlipViewDummy); Image t1 = new Image() { Source = Image_FlipViewDummy.Source }; t1.Effect = new BlurEffect() { Radius = 4.5d, RenderingBias = RenderingBias.Quality, KernelType = KernelType.Gaussian }; Grid_FlipViewDummy.Background = new VisualBrush(t1); aFlipViewAvatarArray[i] = Grid_FlipViewDummy; } FlipViewPersonaImage.ItemsSource = aFlipViewAvatarArray; Binding indexBind = new Binding() { Path = new PropertyPath("ActivePersona.IconIndex"), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay, Source = Access.CurrentSession }; BindingOperations.SetBinding(FlipViewPersonaImage, FlipView.SelectedIndexProperty, indexBind); #endregion #region MetroTile -> Random Persona Info tRandomPersonaInfo_Tick(null, null); RandomPersonaInfo.Tick += new EventHandler(tRandomPersonaInfo_Tick); RandomPersonaInfo.Interval = new TimeSpan(0, 0, 10); RandomPersonaInfo.Start(); #endregion #region carDialog Binding lBindSelect = new Binding() { Path = new PropertyPath("language.Select"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; Binding lBindCancel = new Binding() { Path = new PropertyPath("language.Cancel"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; Binding lBindSelectCar = new Binding() { Path = new PropertyPath("language.AddACarText"), Mode = BindingMode.OneWay, Source = Access.dataAccess.appSettings.uiSettings }; ComboBox carComboBox = new ComboBox(); carComboBox.SetValue(Canvas.LeftProperty, 5d); carComboBox.SetValue(Canvas.TopProperty, 20d); carComboBox.Width = 297d; carComboBox.ItemsSource = CarDefinitions.physicsProfileHashNormal.Values; carComboBox.SelectedIndex = 0; Button selectButton = new Button(); selectButton.SetValue(Canvas.LeftProperty, 148d); selectButton.SetValue(Canvas.TopProperty, 54d); selectButton.Width = 80d; selectButton.Click += (object sender, RoutedEventArgs routedEventArgs) => { CarEntity carEntity = new CarEntity(); carEntity.baseCarId = CarDefinitions.baseCarId.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key; carEntity.carId = Access.CurrentSession.ActivePersona.Cars.Last().CarId + 1; carEntity.durability = 100; carEntity.heatLevel = 1; carEntity.paints = "<Paints/>"; carEntity.performanceParts = "<PerformanceParts/>"; carEntity.physicsProfileHash = CarDefinitions.physicsProfileHashNormal.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key; carEntity.raceClass = CarClass.E; carEntity.rating = 123; carEntity.resalePrice = 0; carEntity.skillModParts = "<SkillModParts/>"; carEntity.vinyls = "<Vinyls/>"; carEntity.visualParts = "<VisualParts/>"; PersonaManagement.addCar(carEntity); DialogManager.HideMetroDialogAsync(this, carDialog); }; Button cancelButton = new Button(); cancelButton.SetValue(Canvas.LeftProperty, 233d); cancelButton.SetValue(Canvas.TopProperty, 54d); cancelButton.Width = 70d; cancelButton.Click += (object sender, RoutedEventArgs routedEventArgs) => { DialogManager.HideMetroDialogAsync(this, carDialog); }; Canvas canvas = new Canvas(); canvas.Children.Add(carComboBox); canvas.Children.Add(selectButton); canvas.Children.Add(cancelButton); carDialog = new CustomDialog(); carDialog.Height = 200d; carDialog.Content = canvas; // internationalization BindingOperations.SetBinding(carDialog, CustomDialog.TitleProperty, lBindSelectCar); BindingOperations.SetBinding(selectButton, Button.ContentProperty, lBindSelect); BindingOperations.SetBinding(cancelButton, Button.ContentProperty, lBindCancel); #endregion }