public string GetPowdertype() { string ret = ""; PowderType tmp = (PowderType)_powdertype; switch (tmp) { case PowderType.POWER_NULL: ret = "Not Used"; break; case PowderType.POWDER_ESPRESSO: ret = "ESPRESSO"; break; case PowderType.POWDER_CHOCOLATE: ret = "CHOCOLATE"; break; case PowderType.POWDER_SUGAR: ret = "SUGAR"; break; case PowderType.POWDER_MILK: ret = "MILK"; break; default: break; } return(ret); }
public async Task <ActionResult <PowderType> > PostPowderType(PowderType powderType) { _context.PowderType.Add(powderType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPowderType", new { id = powderType.Id }, powderType)); }
public async Task <IActionResult> PutPowderType(int id, PowderType powderType) { if (id != powderType.Id) { return(BadRequest()); } _context.Entry(powderType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PowderTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,Name,Notes")] PowderType modEntity) { if (ModelState.IsValid) { this.service.Edit(modEntity); return(RedirectToAction("Index")); } return(View(modEntity)); }
/// <summary> /// Formats the data gathered from the file /// </summary> /// <param name="Data"></param> public void InputBulletData(string filePath, ref BulletType bt) { // Read the file using (TextFieldParser CSVParser = new TextFieldParser(filePath)) { CSVParser.SetDelimiters(","); CSVParser.TrimWhiteSpace = true; // Record the row with the column names string[] ColumnHeaders = CSVParser.ReadFields().Where(x => !string.IsNullOrEmpty(x)).ToArray(); if (ColumnHeaders.Length == 0) { // Empty data file return; } int[] velocities = new int[ColumnHeaders.Length - 1]; if (ColumnHeaders[0].ToLower() != "powder") { // Not reading a data file return; } for (int i = 1; i < ColumnHeaders.Length; ++i) { if (int.TryParse(ColumnHeaders[i], out int newVelocity)) { velocities[i - 1] = newVelocity; } else { // error converting string to double } } // Parse through and gather the remaining data fields while (!CSVParser.EndOfData) { // Read current line fields, pointer moves to the next line. // Fields format should be: [0] -> PowderName [1] -> [end] load ratings i.e., 20.6, 21.1 .. etc. string[] Fields = CSVParser.ReadFields().Where(x => !string.IsNullOrEmpty(x)).ToArray(); if (Fields.Length == 0) { // Should not occur continue; } else if (Fields.Length != velocities.Length + 1) { // Error..should be the same size } // Create new powder type and initialize with the name PowderType pt = new PowderType(Fields[0]); // Input data gathered from file for (int i = 0; i < velocities.Length; ++i) { if (float.TryParse(Fields[i + 1], out float load)) { pt.AddPowderLoadAndVelocity(load, velocities[i]); } else if ((Fields[i + 1].ToLower() == "n/a")) { pt.AddPowderLoadAndVelocity(float.NaN, velocities[i]); } else { // Error } } } } }
public static void Init(EntityManager mgr) { var rand = Rand.Create(); values = new PowderType[MaxType]; values[Void] = new PowderType() { id = Void, }; values[Sand] = new PowderType { color = Utils.ToColor("#eeee10"), id = Sand, state = PowderState.Powder, name = "Sand", creator = (coord) => new Powder { coord = coord, life = -1, type = Sand }, renderer = GetRendererPrototype("Sand") }; values[Wood] = new PowderType { color = Utils.ToColor("#bf9c1d"), id = Wood, state = PowderState.Solid, name = "Wood", creator = (coord) => new Powder { coord = coord, life = -1, type = Wood }, renderer = GetRendererPrototype("Wood") }; values[Fire] = new PowderType { color = Utils.ToColor("#ff0000"), id = Fire, state = PowderState.Gas, name = "Fire", creator = (coord) => new Powder { coord = coord, life = 200 + rand.Range(0, 75), type = Fire }, renderer = GetRendererPrototype("Fire") }; values[Water] = new PowderType { color = Utils.ToColor("#0000ff"), id = Water, state = PowderState.Liquid, name = "Water", creator = (coord) => new Powder { coord = coord, life = -1, type = Water }, renderer = GetRendererPrototype("Water") }; values[Stone] = new PowderType { color = Utils.ToColor("#7f7f7f"), id = Water, state = PowderState.Solid, name = "Stone", creator = (coord) => new Powder { coord = coord, life = -1, type = Stone }, renderer = GetRendererPrototype("Stone"), }; values[Smoke] = new PowderType { color = Utils.ToColor("#878787"), id = Smoke, state = PowderState.Gas, name = "Smoke", creator = (coord) => new Powder { coord = coord, life = 150 + rand.Range(0, 150), type = Smoke }, renderer = GetRendererPrototype("Smoke") }; values[Steam] = new PowderType { color = Utils.ToColor("#e3e3e3"), id = Steam, state = PowderState.Gas, name = "Steam", creator = (coord) => new Powder { coord = coord, life = 200 + rand.Range(0, 200), type = Steam }, renderer = GetRendererPrototype("Steam") }; values[Acid] = new PowderType { color = Utils.ToColor("#ff33ee"), id = Acid, state = PowderState.Liquid, name = "Acid", creator = (coord) => new Powder { coord = coord, life = -1, type = Acid }, renderer = GetRendererPrototype("Acid") }; values[Glass] = new PowderType { color = Utils.ToColor("#404040"), id = Acid, state = PowderState.Solid, name = "Glass", creator = (coord) => new Powder { coord = coord, life = -1, type = Glass }, renderer = GetRendererPrototype("Glass") }; values[Lava] = new PowderType { color = Utils.ToColor("#FF0000"), id = Lava, state = PowderState.Liquid, name = "Lava", creator = (coord) => new Powder { coord = coord, life = -1, type = Lava }, renderer = GetRendererPrototype("Lava") }; values[Lava] = new PowderType { color = Utils.ToColor("#FF0000"), id = Lava, state = PowderState.Liquid, name = "Lava", creator = (coord) => new Powder { coord = coord, life = -1, type = Lava }, renderer = GetRendererPrototype("Lava") }; values[SandGenerator] = new PowderType { color = Utils.ToColor("#777777"), id = SandGenerator, state = PowderState.Solid, name = "Sand Gen", creator = (coord) => new Powder { coord = coord, life = -1, type = SandGenerator }, renderer = GetRendererPrototype("Generator"), generatedElementType = Sand }; values[FireGenerator] = new PowderType { color = Utils.ToColor("#777777"), id = FireGenerator, state = PowderState.Solid, name = "Fire Gen", creator = (coord) => new Powder { coord = coord, life = -1, type = FireGenerator }, renderer = GetRendererPrototype("Generator"), generatedElementType = Fire }; values[WaterGenerator] = new PowderType { color = Utils.ToColor("#777777"), id = WaterGenerator, state = PowderState.Solid, name = "Water Gen", creator = (coord) => new Powder { coord = coord, life = -1, type = WaterGenerator }, renderer = GetRendererPrototype("Generator"), generatedElementType = Water }; values[SmokeGenerator] = new PowderType { color = Utils.ToColor("#777777"), id = SmokeGenerator, state = PowderState.Solid, name = "Smoke Gen", creator = (coord) => new Powder { coord = coord, life = -1, type = SmokeGenerator }, renderer = GetRendererPrototype("Generator"), generatedElementType = Smoke }; values[SteamGenerator] = new PowderType { color = Utils.ToColor("#777777"), id = SteamGenerator, state = PowderState.Solid, name = "Steam Gen", creator = (coord) => new Powder { coord = coord, life = -1, type = SteamGenerator }, renderer = GetRendererPrototype("Generator"), generatedElementType = Steam }; values[AcidGenerator] = new PowderType { color = Utils.ToColor("#777777"), id = AcidGenerator, state = PowderState.Solid, name = "Acid Gen", creator = (coord) => new Powder { coord = coord, life = -1, type = AcidGenerator }, renderer = GetRendererPrototype("Generator"), generatedElementType = Acid }; values[LavaGenerator] = new PowderType { color = Utils.ToColor("#777777"), id = LavaGenerator, state = PowderState.Solid, name = "Lava Gen", creator = (coord) => new Powder { coord = coord, life = -1, type = LavaGenerator }, renderer = GetRendererPrototype("Generator"), generatedElementType = Lava }; }