private void Start() { cam = Camera.main; cc = GetComponentInParent <ComputerComponent>(); if (isSelected) { RaycastHit h; if (Physics.Raycast(transform.position, -Vector3.up, out h)) { if (h.transform.CompareTag("Wire Port")) { wp = h.transform.GetComponent <WirePort>(); pos = h.transform.position; pos.y += .1f; transform.position = pos; isOnWirePort = true; wp.isOpen = false; PowerSupply wpps = wp.GetComponent <PowerSupply>(); if (wpps != null) { wpps.hasBeenPluggedIn = true; } } } isSelected = false; } }
public bool SelectRandomComponent() { bool success = false; int numCompsTested = 0; ComputerComponent component = null; while (component == null && numCompsTested < activatedComponents.Count) { component = activatedComponents[Random.Range(0, activatedComponents.Count)].GetComponent <ComputerComponent>(); if (component.isCooking) { component = null; numCompsTested++; } } if (component != null) { component.StartFire(); success = true; } return(success); }
private void OnCompPowerChange(EntityUid uid, ComputerComponent component, PowerChangedEvent args) { if (TryComp <AppearanceComponent>(uid, out var appearance)) { appearance.SetData(ComputerVisuals.Powered, args.Powered); } }
/// <summary> /// Creates the corresponding computer board on the computer. /// This exists so when you deconstruct computers that were serialized with the map, /// you can retrieve the computer board. /// </summary> private void CreateComputerBoard(ComputerComponent component) { // Ensure that the construction component is aware of the board container. if (TryComp <ConstructionComponent>(component.Owner, out var construction)) { AddContainer(component.Owner, "board", construction); } // We don't do anything if this is null or empty. if (string.IsNullOrEmpty(component.BoardPrototype)) { return; } var container = _container.EnsureContainer <Container>(component.Owner, "board"); // We already contain a board. Note: We don't check if it's the right one! if (container.ContainedEntities.Count != 0) { return; } var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(component.Owner).Coordinates); if (!container.Insert(board)) { Logger.Warning($"Couldn't insert board {board} to computer {component.Owner}!"); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,ComputerId,ComponentId")] ComputerComponent computerComponent) { if (id != computerComponent.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(computerComponent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComputerComponentExists(computerComponent.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ComponentId"] = new SelectList(_context.Component, "Id", "Name", computerComponent.ComponentId); ViewData["ComputerId"] = new SelectList(_context.Computer, "Id", "Name", computerComponent.ComputerId); return(View(computerComponent)); }
public ViewResult Edit(int computercomponentId) { ComputerComponent computercomponent = repository.ComputerComponents .FirstOrDefault(g => g.ComputerComponentId == computercomponentId); return(View(computercomponent)); }
public ComputerComponent DeleteProduct(int computercomponentId) { ComputerComponent dbEntry = context.ComputerComponents.Find(computercomponentId); if (dbEntry != null) { context.ComputerComponents.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public ActionResult DeleteProduct(int computercomponentId) { ComputerComponent deletedProduct = repository.DeleteProduct(computercomponentId); if (deletedProduct != null) { TempData["message"] = string.Format("Product \"{0}\" was deleted", deletedProduct.Name); } return(RedirectToAction("Index")); }
private void OnCompInit(EntityUid uid, ComputerComponent component, ComponentInit args) { // Let's ensure the container manager and container are here. _container.EnsureContainer <Container>(uid, "board"); if (TryComp <ApcPowerReceiverComponent>(uid, out var powerReceiver) && TryComp <AppearanceComponent>(uid, out var appearance)) { appearance.SetData(ComputerVisuals.Powered, powerReceiver.Powered); } }
public RedirectToRouteResult RemoveFromCart(Cart cart, int computercomponentId, string returnUrl) { ComputerComponent component = repository.ComputerComponents .FirstOrDefault(g => g.ComputerComponentId == computercomponentId); if (component != null) { cart.RemoveLine(component); } return(RedirectToAction("Index", new { returnUrl })); }
internal UpperWhiteStation( CentralReactor whiteReactor, ThreatController threatController, Gravolift gravolift, Doors bluewardDoors, Doors redwardDoors, SittingDuck sittingDuck) : base(StationLocation.UpperWhite, threatController, gravolift, bluewardDoors, redwardDoors, sittingDuck) { AlphaComponent = new CentralHeavyLaserCannon(whiteReactor, ZoneLocation.White); Shield = new CentralShield(whiteReactor); ComputerComponent = new ComputerComponent(); }
public async Task <IActionResult> Create([Bind("Id,ComputerId,ComponentId")] ComputerComponent computerComponent) { if (ModelState.IsValid) { _context.Add(computerComponent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ComponentId"] = new SelectList(_context.Component, "Id", "Name", computerComponent.ComponentId); ViewData["ComputerId"] = new SelectList(_context.Computer, "Id", "Name", computerComponent.ComputerId); return(View(computerComponent)); }
public FileContentResult GetImage(int computercomponentId) { ComputerComponent computercomponent = repository.ComputerComponents .FirstOrDefault(g => g.ComputerComponentId == computercomponentId); if (computercomponent != null) { return(File(computercomponent.ImageData, computercomponent.ImageMimeType)); } else { return(null); } }
public ICollection <ComputerComponentDTO> ProductsIntoComputerComponents(List <ProductDTO> products) { List <ComputerComponent> compComponents = new List <ComputerComponent>(); foreach (var pr in products) { ComputerComponent compComp = Database.ComputerComponents.Get(pr.FromTableId); if (compComp != null) { compComponents.Add(compComp); } } return(_mappers.ToComputerComponentDTO.Map <ICollection <ComputerComponent>, ICollection <ComputerComponentDTO> >(compComponents)); }
public void ReplacePart(ComputerComponent comp) { String type = comp.Type; foreach (ComputerComponent currentComp in rgComponents) { if (type == currentComp.Type) { rgComponents.Remove(currentComp); break; } } AddComponent(comp); }
public static ComputerComponent Generate() { ComputerComponent computer = new ComputerComponent() { Ram = 2048, Cpu = new Cpu() { Cores = 1, ClockSpeed = 1024 } }; return(computer); }
//public void BuildComputer(string ProcessorId, string MemoryId, string Hdd, string Software) public async Task <IActionResult> BuildComputer(ComponentVM dataFromView) { Order order = new Order(); Computer computer = new Computer(); ComputerComponent computerComponent = new ComputerComponent(); int orderId = 0; AppUser myCurrentUser = await _userManager.GetUserAsync(User); if (myCurrentUser == null) { //return NotFound(); ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(RedirectToAction(nameof(Index))); } Order orderAssociatedWUser = await _orderService.GetOrderItemAsync(false); //.ToListAsync(); if (orderAssociatedWUser == null) { order.Price += _helperService.GetComputerTotalPrice(dataFromView); order.Qty = 1; order.IsCart = false; order.AppUserId = myCurrentUser.Id; orderId = await _helperService.InsertOrderToDBAsync(order); } else { orderId = orderAssociatedWUser.Id; } computer.Name = _helperService.CUSTOM_COMPUTER_NAME; computer.Price = _helperService.GetComputerTotalPrice(dataFromView); computer.IsDesktop = true; computer.ImgUrl = "https://c1.neweggimages.com/NeweggImage/ProductImage/83-221-575-V09.jpg"; int computerId = await _helperService.InsertComputerToDBAsync(computer); int computerComponentId = await _helperService.InsertComponentsToComputerComponentDBAsync(dataFromView, computerId, orderId); int computerOrderId = await _helperService.InsertComputerOrderToDBAsync(orderId, computerId); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(ComputerComponent computercomponent, HttpPostedFileBase image = null) { if (ModelState.IsValid) { if (image != null) { computercomponent.ImageMimeType = image.ContentType; computercomponent.ImageData = new byte[image.ContentLength]; image.InputStream.Read(computercomponent.ImageData, 0, image.ContentLength); } repository.SaveProduct(computercomponent); TempData["message"] = string.Format("Changes in product \"{0}\" were saved", computercomponent.Name); return(RedirectToAction("Index")); } else { // Smth wrong with data return(View(computercomponent)); } }
public void SaveProduct(ComputerComponent computercomponent) { if (computercomponent.ComputerComponentId == 0) { context.ComputerComponents.Add(computercomponent); } else { ComputerComponent dbEntry = context.ComputerComponents.Find(computercomponent.ComputerComponentId); if (dbEntry != null) { dbEntry.Name = computercomponent.Name; dbEntry.Description = computercomponent.Description; dbEntry.Price = computercomponent.Price; dbEntry.Category = computercomponent.Category; dbEntry.ImageData = computercomponent.ImageData; dbEntry.ImageMimeType = computercomponent.ImageMimeType; } } context.SaveChanges(); }
public OperationDetails UpdateComputerComponent(ProductDTO product, ComputerComponentDTO item, string oldComputerComponentName) { if (product == null || item == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Product localProduct = UpdateProduct(product); Database.Products.Update(localProduct); ComputerComponent oldComputerComponent = Database.ComputerComponents.Find(x => x.Name == oldComputerComponentName).FirstOrDefault(); if (oldComputerComponent == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } oldComputerComponent.Type = item.Type; oldComputerComponent.Properties = _mappers.ToProperty.Map <IEnumerable <PropertyDTO>, ICollection <Property> >(item.Properties); Database.ComputerComponents.Update(oldComputerComponent); Database.Save(); return(new OperationDetails(true, "Компьютерный компонент успешно изменён", this.ToString())); }
public void CompositeTest() { // Arrange var computer = new Computer("Cheap Computer"); var motherboard = new ComputerComponent("Motherboard", 100); var cpu = new ComputerComponent("CPU", 150); var monitor = new ComputerComponent("Monitor", 50); computer.AddRange(new[] { motherboard, cpu, monitor }); // Act var price = computer.GetPrice(); // Assert Assert.AreEqual(300, price); Assert.AreEqual("Cheap Computer", computer.GetName()); Assert.AreEqual("Motherboard", motherboard.GetName()); Assert.AreEqual(100, motherboard.GetPrice()); Assert.AreEqual("CPU", cpu.GetName()); Assert.AreEqual(150, cpu.GetPrice()); Assert.AreEqual("Monitor", monitor.GetName()); Assert.AreEqual(50, monitor.GetPrice()); }
public async Task <int> InsertComponentsToComputerComponentDBAsync(ComponentVM component, int computerId, int orderId) { Type type = typeof(ComponentVM); int NumberOfRecords = type.GetProperties().Length; int[] idArray = new int[NumberOfRecords]; ComputerComponent computerComponent = new ComputerComponent(); idArray[0] = component.HddId; idArray[1] = component.SoftwareId; idArray[2] = component.ProcessorId; idArray[3] = component.MemoryId; idArray[4] = component.OSId; //computerComponent.ComputerId = computerId; foreach (var item in idArray) { computerComponent = new ComputerComponent(); computerComponent.ComputerId = computerId; computerComponent.ComponentId = item; //computerComponent.OrderId = orderId; _context.Add(computerComponent); await _context.SaveChangesAsync(); } return(computerComponent.Id); }
void ComponentInstallation(Collider other) { //Check if the name of the object this script is attached matches to the name of the socket assign int he collided objects array computerComponent = other.GetComponent <ComputerComponent>(); componentName = computerComponent.component[0]; //For debugging the name of the component socketName = computerComponent.component[1]; //Retrieve the name of the socket that was assigned to the component array componentTransform = other.gameObject.GetComponent <Transform>(); //Access the transform of the socket object this script is attached to //Check if socket has a component game object attached, if not then perform the component checking if (socketTransform.childCount == 0) { //If the component is collding with socket collidor and the user is not holding down the trigger, place component in socket if (playerControls.isTriggerHeld == false) { //Check if the component socket name is the same as the name of this game object, if so then it is the correct socket for component to be installed on if (socketName == gameObject.name) { InstallComponent(componentTransform, socketTransform, computerComponent); } } } }
public OperationDetails CreateComputerComponent(ProductDTO product, ComputerComponentDTO item, string oldComputerComponent) { Product productInDB = Database.Products.Find(p => p.Name == oldComputerComponent).FirstOrDefault(); if (productInDB != null) { return(UpdateComputerComponent(product, item, oldComputerComponent)); } if (item == null || product == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } item.Name = product.Name; Database.ComputerComponents.Add(_mappers.ToComputerComponent.Map <ComputerComponentDTO, ComputerComponent>(item)); Database.Save(); Product localProduct = _mappers.ToProduct.Map <ProductDTO, Product>(product); if (localProduct == null) { return(new OperationDetails(false, "Не удалось преобразовать объект", this.ToString())); } localProduct = CreateProduct(localProduct); localProduct.Table = Goods.ComputerComponent; ComputerComponent computerComponent = Database.ComputerComponents.Find(x => x.Name == localProduct.Name).FirstOrDefault(); if (computerComponent == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } localProduct.FromTableId = computerComponent.Id; Database.Products.Add(localProduct); Database.Save(); return(new OperationDetails(true, "Компьютерный компонент был успешно добавлен", this.ToString())); }
public void InstallComponent(Transform componentTransform, Transform socketTransform, ComputerComponent computerComponent) { componentTransform.parent = socketTransform; //Attach component to socket componentTransform.position = socketTransform.position; //Positions the component to the same position as the node object componentTransform.rotation = socketTransform.rotation; //Rotate the component to the same rotation as the node object //Set the booleon isComponentInstalled for that component to true computerComponent.SetComponentInstalledToTrue(); //Add 1 to the variable componentsInstalled to show that a component has been installed countCompInstall.componentsInstalled++; Debug.Log("Components Installed: " + countCompInstall.componentsInstalled); //Disable collidor so the Trigger events are no longer running for the socket object that contains a component attached gameObject.GetComponent <BoxCollider>().enabled = false; //Disables the box collider on the component so the user cannot pick up the component again once it is installed componentTransform.gameObject.GetComponent <BoxCollider>().enabled = false; }
public OperationDetails UpdateComputer(ProductDTO product, ComputerDTO item, string oldComputerName) { if (product == null || item == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Product localProduct = UpdateProduct(product); Database.Products.Update(localProduct); Computer oldComputer = Database.Computers.Find(x => x.Name == oldComputerName).FirstOrDefault(); if (oldComputer == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } if (item.MotherBoard != null && item.MotherBoard.Type == ComponentType.MotherBoard) { ComputerComponent motherBoard = Database.ComputerComponents.Find(c => c.Name == item.MotherBoard.Name).FirstOrDefault(); if (motherBoard == null) { return(new OperationDetails(false, "Не удалось найти материнскую плату", this.ToString())); } oldComputer.MotherBoard = motherBoard; } if (item.PowerSupply != null && item.MotherBoard.Type == ComponentType.PowerSupply) { ComputerComponent powerSypply = Database.ComputerComponents.Find(c => c.Name == item.PowerSupply.Name).FirstOrDefault(); if (powerSypply == null) { return(new OperationDetails(false, "Не удалось найти блок питания", this.ToString())); } oldComputer.PowerSupply = powerSypply; } if (item.Processor != null && item.MotherBoard.Type == ComponentType.Processor) { ComputerComponent processor = Database.ComputerComponents.Find(c => c.Name == item.Processor.Name).FirstOrDefault(); if (processor == null) { return(new OperationDetails(false, "Не удалось найти процессор", this.ToString())); } oldComputer.Processor = processor; } if (item.SystemBlock != null && item.MotherBoard.Type == ComponentType.SystemBlock) { ComputerComponent systemBlock = Database.ComputerComponents.Find(c => c.Name == item.SystemBlock.Name).FirstOrDefault(); if (systemBlock == null) { return(new OperationDetails(false, "Не удалось найти системный блок", this.ToString())); } oldComputer.SystemBlock = systemBlock; } List <ComputerComponent> RAMs = new List <ComputerComponent>(); foreach (var r in item.RAM) { ComputerComponent ram = Database.ComputerComponents.Find(c => c.Name == r.Name && c.Type == ComponentType.RAM).FirstOrDefault(); if (ram == null) { return(new OperationDetails(false, "Не удалось найти оперативную память", this.ToString())); } RAMs.Add(ram); } oldComputer.RAM = RAMs; List <ComputerComponent> ROMs = new List <ComputerComponent>(); foreach (var r in item.ROM) { ComputerComponent rom = Database.ComputerComponents.Find(c => c.Name == r.Name && c.Type == ComponentType.ROM).FirstOrDefault(); if (rom == null) { return(new OperationDetails(false, "Не удалось найти постоянную память", this.ToString())); } ROMs.Add(rom); } oldComputer.ROM = ROMs; List <ComputerComponent> videoCards = new List <ComputerComponent>(); foreach (var v in item.VideoCard) { ComputerComponent videoCard = Database.ComputerComponents.Find(c => c.Name == v.Name && c.Type == ComponentType.VideoCard).FirstOrDefault(); if (videoCard == null) { return(new OperationDetails(false, "Не удалось найти видеокарту", this.ToString())); } videoCards.Add(videoCard); } oldComputer.VideoCard = videoCards; oldComputer.Properties = _mappers.ToProperty.Map <IEnumerable <PropertyDTO>, ICollection <Property> >(item.Properties); Database.Computers.Update(oldComputer); Database.Save(); return(new OperationDetails(true, "Компьютер успешно изменён", this.ToString())); }
private void OnCompMapInit(EntityUid uid, ComputerComponent component, MapInitEvent args) { CreateComputerBoard(component); }
public void AddComponent(ComputerComponent comp) { rgComponents.Add(comp); }
public List <AssemblerContent> GetAssemblerInv() { List <AssemblerContent> assemblerContents = new List <AssemblerContent>(); assemblerContents.Add(new AssemblerContent() { componentName = "" + SteelPlate.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + ConstructionComponent.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + InteriorPlate.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + SmallTube.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + MotorComponent.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + ComputerComponent.ToString().Split('/')[1], amount = 0 }); assemblerContents.Add(new AssemblerContent() { componentName = "" + Display.ToString().Split('/')[1], amount = 0 }); foreach (var assembler in Assemblers) { // Output inventory List <MyInventoryItem> iTmp = new List <MyInventoryItem>(); assembler.GetInventory(1).GetItems(iTmp); foreach (var item in iTmp) { string name = item.Type.ToString().Split('/')[1]; var ac = assemblerContents.Where(y => y.componentName.Equals(name)).FirstOrDefault(); if (ac != null) { ac.amount += item.Amount.ToIntSafe(); } else { Message = "Unusuable component in assembler inventory. \nComponent: " + name; } } // Production Queue List <MyProductionItem> qTmp = new List <MyProductionItem>(); assembler.GetQueue(qTmp); foreach (var item in qTmp) { string name = item.BlueprintId.ToString().Split('/')[1]; var ac = assemblerContents.Where(y => y.componentName.Equals(name)).FirstOrDefault(); if (ac != null) { ac.amount += item.Amount.ToIntSafe(); } else { Message = "Unusuable component in assembler queue. \nComponent: " + name; } } } return(assemblerContents); }
//TODO: Wire up all 3 stations if variable range interceptors are allowed public SittingDuck() { CurrentThreatBuffs = new Dictionary <ExternalThreat, ExternalThreatBuff>(); CurrentInternalThreats = new List <InternalThreat>(); CurrentExternalThreats = new List <ExternalThreat>(); var whiteReactor = new CentralReactor(); var redReactor = new SideReactor(whiteReactor); var blueReactor = new SideReactor(whiteReactor); var redBatteryPack = new BatteryPack(); var blueBatteryPack = new BatteryPack(); var computerComponent = new ComputerComponent(); var visualConfirmationComponent = new VisualConfirmationComponent(); var rocketsComponent = new RocketsComponent(); Computer = computerComponent; VisualConfirmationComponent = visualConfirmationComponent; RocketsComponent = rocketsComponent; var interceptorStation = new InterceptorStation { StationLocation = StationLocation.Interceptor }; var upperRedStation = new StandardStation { Cannon = new SideHeavyLaserCannon(redReactor, ZoneLocation.Red), EnergyContainer = new SideShield(redReactor), StationLocation = StationLocation.UpperRed }; interceptorStation.InterceptorComponent = new InterceptorComponent(null, upperRedStation); upperRedStation.CComponent = new InterceptorComponent(interceptorStation, null); var upperWhiteStation = new StandardStation { Cannon = new CentralHeavyLaserCannon(whiteReactor, ZoneLocation.White), EnergyContainer = new CentralShield(whiteReactor), StationLocation = StationLocation.UpperWhite, CComponent = computerComponent }; var upperBlueStation = new StandardStation { Cannon = new SideHeavyLaserCannon(blueReactor, ZoneLocation.Blue), EnergyContainer = new SideShield(blueReactor), StationLocation = StationLocation.UpperBlue, CComponent = new BattleBotsComponent() }; var lowerRedStation = new StandardStation { Cannon = new SideLightLaserCannon(redBatteryPack, ZoneLocation.Red), EnergyContainer = redReactor, StationLocation = StationLocation.LowerRed, CComponent = new BattleBotsComponent() }; var lowerWhiteStation = new StandardStation { Cannon = new PulseCannon(whiteReactor), EnergyContainer = whiteReactor, StationLocation = StationLocation.LowerWhite, CComponent = visualConfirmationComponent }; var lowerBlueStation = new StandardStation { Cannon = new SideLightLaserCannon(blueBatteryPack, ZoneLocation.Blue), EnergyContainer = blueReactor, StationLocation = StationLocation.LowerBlue, CComponent = rocketsComponent }; upperRedStation.BluewardStation = upperWhiteStation; upperRedStation.OppositeDeckStation = lowerRedStation; upperWhiteStation.RedwardStation = upperRedStation; upperWhiteStation.BluewardStation = upperBlueStation; upperWhiteStation.OppositeDeckStation = lowerWhiteStation; upperBlueStation.RedwardStation = upperWhiteStation; upperBlueStation.OppositeDeckStation = lowerBlueStation; lowerRedStation.BluewardStation = lowerWhiteStation; lowerRedStation.OppositeDeckStation = upperRedStation; lowerWhiteStation.RedwardStation = lowerRedStation; lowerWhiteStation.BluewardStation = lowerBlueStation; lowerWhiteStation.OppositeDeckStation = upperWhiteStation; lowerBlueStation.RedwardStation = lowerWhiteStation; lowerBlueStation.OppositeDeckStation = upperBlueStation; RedZone = new Zone { LowerStation = lowerRedStation, UpperStation = upperRedStation, ZoneLocation = ZoneLocation.Red, Gravolift = new Gravolift() }; WhiteZone = new Zone { LowerStation = lowerWhiteStation, UpperStation = upperWhiteStation, ZoneLocation = ZoneLocation.White, Gravolift = new Gravolift() }; BlueZone = new Zone { LowerStation = lowerBlueStation, UpperStation = upperBlueStation, ZoneLocation = ZoneLocation.Blue, Gravolift = new Gravolift() }; ZonesByLocation = new[] { RedZone, WhiteZone, BlueZone }.ToDictionary(zone => zone.ZoneLocation); StationByLocation = Zones .SelectMany(zone => new[] { zone.LowerStation, zone.UpperStation }) .Concat(new Station[] { interceptorStation }) .ToDictionary(station => station.StationLocation); InterceptorStation = interceptorStation; }