public void propMaterialGetMPIsotropic(BuildingMaterial material) { string message = "VRE to SAPTranslator: propMaterialGetMPIsotropic(" + material.GetName() + ")"; sendString(message); material.MPIsotropic = readPropMaterialGetMPIsotropic(); }
public void addBuildingMaterialToXMLList(BuildingMaterial buildingMaterial) { BuildingMaterialForXML newElement = new BuildingMaterialForXML(buildingMaterial.GetName(), buildingMaterial.GetRegion(), buildingMaterial.GetMaterialType(), buildingMaterial.GetStandard(), buildingMaterial.GetGrade()); elementsListsForXML.buildingMaterialForXMLList.Add(newElement); saveToXML(); }
/// <summary> /// Construct a new material. This is called by the UI create materials page /// Returns the material /// </summary> public BuildingMaterial addBuildingMaterial(string givenName, string region, string type, string standard, string grade) { BuildingMaterial newMaterial = new BuildingMaterial(givenName, region, type, standard, grade); addBuildingMaterial(newMaterial); return(newMaterial); }
public void Interact() { if (SupplySlots.Count <= 0) { return; } InventoryItemStack currentItem = Toolbar.Instance.SelectedSlot.ReferencedItemStack; if (currentItem == null) { return; } BuildingMaterial currentSlot = new BuildingMaterial(); bool foundSlot = false; int i = 0; for (i = i; i < SupplySlots.Count - 1; i++) { if (SupplySlots[i].ContainedItem.ID == currentItem.ContainedItem.ID) { if (SupplySlots[i].CurrentAmount >= SupplySlots[i].TargetAmount) { return; } break; } } currentSlot = SupplySlots[i]; currentSlot.CurrentAmount += 1; SupplySlots[i] = currentSlot; FindObjectOfType <PlayerInventory>().RemoveFromStack(currentItem); }
/// <summary> /// Initialize this entry using the specified building list enty /// </summary> /// <param name="entry">entry whose contest should be displayed</param> /// <param name="buildingMaterial">buildingMaterial this entry comes from</param> public void Initialize(BuildList.Entry entry, BuildingMaterial buildingMaterial) { this.entry = entry; this.buildingMaterial = buildingMaterial; image.sprite = null; secondaryImage.sprite = null; tertiaryImage.sprite = null; materialImage.sprite = null; materialSecondaryImage.sprite = null; entryName.text = null; materialCost.text = null; if (entry.Prefab) { entry.Prefab.PopulateImageSprites(image, secondaryImage, tertiaryImage); } else { Logger.LogError($"Construction Entry {entry.Name} doesn't use prefab"); } entryName.text = entry.Name; buildingMaterial.gameObject.PopulateImageSprites(materialImage, materialSecondaryImage); materialCost.text = entry.Cost.ToString(); }
public async Task <IActionResult> Edit(int id, [Bind("BuildingMaterialId,NameMaterial,ManufacturerId,VolumePurchaseQuantity,ContractorId")] BuildingMaterial buildingMaterial) { if (id != buildingMaterial.BuildingMaterialId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(buildingMaterial); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuildingMaterialExists(buildingMaterial.BuildingMaterialId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ContractorId"] = new SelectList(_context.Contractors, "ContractorId", "NameCompany", buildingMaterial.ContractorId); ViewData["ManufacturerId"] = new SelectList(_context.Manufacturers, "ManufacturerId", "ManufacturerName", buildingMaterial.ManufacturerId); return(View(buildingMaterial)); }
public void init(string text, MaterialsEditor editor, BuildingMaterial mat, int id) { this.material = mat; myText.text = text; this.GetComponent <Button>().onClick.AddListener(onClick); this.editor = editor; this.id = id; }
/// <summary> /// Sets the current building material that the user is using /// </summary> public void setCurrentMaterial(string name) { BuildingMaterial bm = findBuildingMaterialWithName(name); if (bm != null) { currentMaterial = bm; } }
public void OpenMaterialAttr(BuildingMaterial mat, int id) { Type.text = mat.Type; X.text = mat.Dimensions.x.ToString(); Y.text = mat.Dimensions.y.ToString(); Z.text = mat.Dimensions.z.ToString(); Weight.text = mat.Weight.ToString(); editing = id; }
public int Take(BuildingMaterial material, int requestedAmount) { if (currentMaterials.TryGetValue(material, out int incontainer)) { int taken = Mathf.Min(incontainer, requestedAmount); currentMaterials[material] -= taken; return(taken); } throw new NoMaterialInContainerException(); }
private void setMaterialList(BuildingConfigurations buildingConfig) { materialList = new List <Material>(); for (int k = 0; k < buildingConfig.defaultSkins.Count; k++) { BuildingMaterial bmat = buildingConfig.defaultSkins[k]; Material mat = InGameTextureHandler.createMaterial2(bmat.colorTexturePath, bmat.normalTexturePath, bmat.specularTexturePath); materialList.Add(mat); } }
public bool CanTake(BuildingMaterial material, int count) { if (materialsInContainer.ContainsKey(material)) { return(materialsInContainer[material] >= count); } else { return(false); } }
public override BuildingMaterial TakeMaterial(Transform carryPos) { //deparent the log //lmao this will all have to change BuildingMaterial _log = UpgradeModels[1].GetComponent <BuildingMaterial>(); _log.transform.parent = carryPos;//the log _log.transform.DOLocalMove(Vector3.zero, 0.5f); _log.transform.DOLocalRotate(Vector3.zero, 0.5f); MyCube.UpgradeTile(CubeUpgradeTypes.Nil); return(_log); }
public async Task <IActionResult> Create([Bind("BuildingMaterialId,NameMaterial,ManufacturerId,VolumePurchaseQuantity,ContractorId")] BuildingMaterial buildingMaterial) { if (ModelState.IsValid) { _context.Add(buildingMaterial); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContractorId"] = new SelectList(_context.Contractors, "ContractorId", "NameCompany", buildingMaterial.ContractorId); ViewData["ManufacturerId"] = new SelectList(_context.Manufacturers, "ManufacturerId", "ManufacturerName", buildingMaterial.ManufacturerId); return(View(buildingMaterial)); }
public bool TransferTo(IContainer container, BuildingMaterial material, int amount) { if (!CanTake(material, amount)) { return(false); } if (container.CanPut(material, amount)) { Take(material, amount); container.Put(material, amount); return(true); } return(false); }
public int TryTransferTo(IContainer container, BuildingMaterial material, int amount) { int transfered = 0; for (int i = amount; i > 0; i--) { if (TransferTo(container, material, i)) { transfered = i; break; } } return(transfered); }
/// <summary> /// Adds a BuildingMaterial to the list of materials /// This is called after a new material is created given its name or name and parameters /// Also sends the data to SAP Translator, /// and tells SAP Translator to set the MPIsotropic object of the material. (currently commented-out) /// </summary> public void addBuildingMaterial(BuildingMaterial newMaterial) { buildingMaterials.Add(newMaterial); myXmlController.GetComponent <xmlController>().addBuildingMaterialToXMLList(newMaterial); string sapTranslatorCommand = "VRE to SAPTranslator: propMaterialAddMaterial(" + newMaterial.GetMaterialType() + ", " + newMaterial.GetRegion() + ", " + newMaterial.GetStandard() + ", " + newMaterial.GetGrade() + ", " + newMaterial.GetName() + ")"; // arguments: (matType, region, standard, grade, userName) mySapTranslatorIpcHandler.enqueueToOutputBuffer(sapTranslatorCommand); //mySapTranslatorIpcHandler.propMaterialGetMPIsotropic(newMaterial); }
public void Put(BuildingMaterial material, int amount) { if (currentMaterials.TryGetValue(material, out int incontainer)) { if (!CanPut(material, amount)) { throw new ContainerIsFullException(); } currentMaterials[material] += amount; } else { throw new NoMaterialInContainerException(); } }
// Throws exception if container is full public void Put(BuildingMaterial material, int amount) { if (CanPut(material, amount)) { FreeSpace -= material.Volume * amount; Weight += material.Weight * amount; if (!materialsInContainer.TryAdd(material, amount)) { materialsInContainer[material] += amount; } } else { throw new ContainerIsFullException(); } }
/// <summary> /// Request constructing the given entry /// </summary> /// <param name="entry">entry to build</param> /// <param name="hasMenu">has construction menu component of the object being used to /// construct.</param> /// <returns></returns> public static RequestBuildMessage Send(BuildList.Entry entry, BuildingMaterial hasMenu) { int entryIndex = hasMenu.BuildList.Entries.ToList().IndexOf(entry); if (entryIndex == -1) { return(null); // entryIndex was previously a byte, which made this check impossible. } RequestBuildMessage msg = new RequestBuildMessage { EntryIndex = (byte)entryIndex }; msg.Send(); return(msg); }
//TODO: Implement, model kinda after dev spawner. /// <summary> /// Displays the menu for the buildingMaterial /// </summary> /// <param name="buildingMaterial"></param> public void ShowBuildMenu(BuildingMaterial buildingMaterial) { transform.GetChild(0).gameObject.SetActive(true); currentBuildingMaterial = buildingMaterial; //delete previous results foreach (Transform child in contentPanel.transform) { Destroy(child.gameObject); } //display new results foreach (var entry in buildingMaterial.BuildList.Entries) { CreateListItem(entry); } }
public int Take(BuildingMaterial material, int requestedAmount) { int returnedAmount = 0; if (materialsInContainer.TryGetValue(material, out int amountInContainer)) { returnedAmount = Mathf.Min(amountInContainer, requestedAmount); materialsInContainer[material] -= returnedAmount; Weight -= material.Weight * returnedAmount; FreeSpace += material.Volume * returnedAmount; } else { throw new NoMaterialInContainerException(); } return(returnedAmount); }
/// <summary> /// Request constructing the given entry /// </summary> /// <param name="entry">entry to build</param> /// <param name="hasMenu">has construction menu component of the object being used to /// construct.</param> /// <returns></returns> public static RequestBuildMessage Send(BuildList.Entry entry, BuildingMaterial hasMenu) { byte entryIndex = (byte)hasMenu.BuildList.Entries.ToList().IndexOf(entry); if (entryIndex == -1) { return(null); } RequestBuildMessage msg = new RequestBuildMessage { EntryIndex = entryIndex }; msg.Send(); return(msg); }
/// <summary> /// Deletes a building material given its name /// </summary> public void deleteBuildingMaterialWithName(string name) { BuildingMaterial bm = findBuildingMaterialWithName(name); if (bm != null) { buildingMaterials.Remove(bm); myXmlController.GetComponent <xmlController>().deletebuildingMaterialFromXMLList(name); string sapTranslatorCommand = "VRE to SAPTranslator: propMaterialDelete(" + bm.GetName() + ")"; // arguments: (name) mySapTranslatorIpcHandler.enqueueToOutputBuffer(sapTranslatorCommand); } if (buildingMaterials.Count == 0) { //addBuildingMaterial(defaultBuildingMaterial); } }
private void WorkTarget() { timer += Time.deltaTime; //time between works if (timer < TimeBetweenWorks) { return; } timer = 0; //work upgrade til work is done if (CurrentWorkTarget.WorkUpgrade(CalculateWork())) { //collect resrouce CarriedMaterial = CurrentWorkTarget.TakeMaterial(BuildingMaterialCarryPos); CurrentAI = NextAI; CurrentWorkTarget = null; } }
/// <summary> /// Initialize this entry using the specified building list enty /// </summary> /// <param name="entry">entry whose contest should be displayed</param> /// <param name="buildingMaterial">buildingMaterial this entry comes from</param> public void Initialize(BuildList.Entry entry, BuildingMaterial buildingMaterial) { this.entry = entry; this.buildingMaterial = buildingMaterial; image.sprite = null; secondaryImage.sprite = null; materialImage.sprite = null; materialSecondaryImage.sprite = null; entryName.text = null; materialCost.text = null; entry.Prefab.PopulateImageSprites(image, secondaryImage); entryName.text = entry.Name; buildingMaterial.gameObject.PopulateImageSprites(materialImage, materialSecondaryImage); materialCost.text = entry.Cost.ToString(); }
public static NetMessage Send(BuildList.Entry entry, BuildingMaterial hasMenu, ConveyorBelt.ConveyorDirection direction) { var entryIndex = hasMenu.BuildList.Entries.ToList().IndexOf(entry); if (entryIndex == -1) { return(new NetMessage()); } var msg = new NetMessage { EntryIndex = (byte)entryIndex, Direction = direction }; Send(msg); return(msg); }
private static SlotContainer ParseBuildingMaterials(string filename) { var result = new SlotContainer(); var content = File.ReadAllLines(filename); BuildingMaterial material = new BuildingMaterial(); int amount; for (int i = 0; i < content.Length; i++) { if (i % 2 == 0) { material = BuildingMaterial.existingMaterials[content[i]]; } else { amount = int.Parse(content[i]); result.AddSlot(material, amount); } } return(result); }
public void OpenConveyorBuildMenu(BuildList.Entry entry, BuildingMaterial materials) { this.materials = materials; this.entry = entry; gameObject.SetActive(true); }
public void ShowConveyorBeltMenu(BuildList.Entry entry, BuildingMaterial buildingMaterial) { CloseBuildMenu(); conveyorBuildMenu.OpenConveyorBuildMenu(entry, buildingMaterial); }