// Function from file: mech_fabricator.dm public int add_to_queue(Design D = null) { if (!(this.queue is ByTable)) { this.queue = new ByTable(); } if (D != null) { this.queue[++this.queue.len] = D; } return(this.queue.len); }
// Function from file: research.dm public void RefreshResearch( ) { Tech PT = null; Design PD = null; dynamic v = null; dynamic T = null; dynamic v2 = null; Design D = null; foreach (dynamic _a in Lang13.Enumerate(this.possible_tech, typeof(Tech))) { PT = _a; if (Lang13.Bool(this.TechHasReqs(PT))) { this.AddTech2Known(PT); } } foreach (dynamic _b in Lang13.Enumerate(this.possible_designs, typeof(Design))) { PD = _b; if (Lang13.Bool(this.DesignHasReqs(PD))) { this.AddDesign2Known(PD); } } foreach (dynamic _c in Lang13.Enumerate(this.known_tech)) { v = _c; T = this.known_tech[v]; T.level = Num13.MaxInt(1, Num13.MinInt(Convert.ToInt32(T.level), 20)); } foreach (dynamic _d in Lang13.Enumerate(this.known_designs)) { v2 = _d; D = this.known_designs[v2]; D.CalcReliability(this.known_tech); } return; }
// Function from file: mech_fabricator.dm public void remove_resources(Design D = null) { dynamic resource = null; foreach (dynamic _a in Lang13.Enumerate(D.materials)) { resource = _a; if (this.resources.Contains(resource)) { this.resources[resource] -= this.get_resource_cost_w_coeff(D, resource); } } return; }
// Function from file: mech_fabricator.dm public bool process_queue( ) { Design D = null; D = this.queue[1]; if (!(D != null)) { this.remove_from_queue(1); if (this.queue.len != 0) { return(this.process_queue()); } else { return(false); } } this.temp = null; while (D != null) { if ((this.stat & 3) != 0) { return(false); } if (!this.check_resources(D)) { this.visible_message(new Txt().icon(this).str(" <b>").The(this).item().str("</b> beeps, \"Not enough resources. Queue processing stopped.\"").ToString()); this.temp = new Txt("<span class='alert'>Not enough resources to build next part.</span><br>\n <a href='?src=").Ref(this).str(";process_queue=1'>Try again</a> | <a href='?src=").Ref(this).str(";clear_temp=1'>Return</a><a>").ToString(); return(false); } this.remove_from_queue(1); this.build_part(D); D = GlobalFuncs.listgetindex(this.queue, 1); } this.visible_message(new Txt().icon(this).str(" <b>").The(this).item().str("</b> beeps, \"Queue processing finished successfully.\"").ToString()); return(false); }
// Function from file: mech_fabricator.dm public dynamic output_part_cost(Design D = null) { int i = 0; dynamic output = null; dynamic c = null; i = 0; foreach (dynamic _a in Lang13.Enumerate(D.materials)) { c = _a; if (this.resources.Contains(c)) { output += "" + (i != 0 ? " | " : null) + this.get_resource_cost_w_coeff(D, c) + " " + this.material2name(c); i++; } } return(output); }
// Function from file: circuitprinter.dm public bool check_mat(Design being_built = null, dynamic M = null) { dynamic _a = M; // Was a switch-case, sorry for the mess. if (_a == "$glass") { return(this.g_amount - Convert.ToDouble(being_built.materials[M] / this.efficiency_coeff) >= 0); } else if (_a == "$gold") { return(this.gold_amount - Convert.ToDouble(being_built.materials[M] / this.efficiency_coeff) >= 0); } else if (_a == "$diamond") { return(this.diamond_amount - Convert.ToDouble(being_built.materials[M] / this.efficiency_coeff) >= 0); } else { return(this.reagents.has_reagent(M, Lang13.DoubleNullable(being_built.materials[M] / this.efficiency_coeff)) != 0); } return(false); }
// Function from file: mech_fabricator.dm public bool check_resources(Design D = null) { dynamic R = null; foreach (dynamic _a in Lang13.Enumerate(D.materials)) { R = _a; if (this.resources.Contains(R)) { if (Convert.ToDouble(this.resources[R]) < this.get_resource_cost_w_coeff(D, R)) { return(false); } } else { return(false); } } return(true); }
// Function from file: mech_fabricator.dm public bool build_part(Design D = null) { Tile location = null; dynamic I = null; this.being_built = D; this.desc = new Txt("It's building ").a(Lang13.Initial(D, "name")).item().str(".").ToString(); this.remove_resources(D); this.overlays.Add("fab-active"); this.use_power = 2; this.updateUsrDialog(); Task13.Sleep(((int)(this.get_construction_time_w_coeff(D)))); this.use_power = 1; this.overlays.Remove("fab-active"); this.desc = Lang13.Initial(this, "desc"); location = Map13.GetStep(this, this.dir); I = Lang13.Call(D.build_path, location); I.materials["$metal"] = this.get_resource_cost_w_coeff(D, "$metal"); I.materials["$glass"] = this.get_resource_cost_w_coeff(D, "$glass"); this.visible_message(new Txt().icon(this).str(" <b>").The(this).item().str("</b> beeps, \"").The(I).item().str(" is complete.\"").ToString()); this.being_built = null; this.updateUsrDialog(); return(true); }
// Function from file: research.dm public int?DesignHasReqs(Design D = null) { dynamic req = null; dynamic known = null; if (D.req_tech.len == 0) { return(GlobalVars.TRUE); } foreach (dynamic _a in Lang13.Enumerate(D.req_tech)) { req = _a; known = this.known_tech[req]; if (!Lang13.Bool(known) || Convert.ToDouble(known.level) < Convert.ToDouble(D.req_tech[req])) { return(GlobalVars.FALSE); } } return(GlobalVars.TRUE); }
// Function from file: mech_fabricator.dm public double get_resource_cost_w_coeff(Design D = null, dynamic resource = null, double?roundto = null) { roundto = roundto ?? 1; return(Num13.Round(Convert.ToDouble(D.materials[resource] * this.resource_coeff * this.resource_coeff_tech), roundto ?? 0)); }
// Function from file: mech_fabricator.dm public double get_construction_time_w_coeff(Design D = null, double?roundto = null) { roundto = roundto ?? 1; return(Num13.Round(Convert.ToDouble(Lang13.Initial(D, "construction_time") * this.time_coeff * this.time_coeff_tech), roundto ?? 0)); }
// Function from file: mech_fabricator.dm public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null) { TopicInput filter = null; string tpart_set = null; string T = null; dynamic v = null; Design D = null; string T2 = null; dynamic v2 = null; Design D2 = null; dynamic index = null; dynamic new_index = null; string T3 = null; dynamic v3 = null; Design D3 = null; dynamic part = null; double? amount = null; string material = null; double removed = 0; if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc)))) { return(null); } filter = new TopicInput(href, href_list); if (Lang13.Bool(href_list["part_set"])) { tpart_set = filter.getStr("part_set"); if (Lang13.Bool(tpart_set)) { if (tpart_set == "clear") { this.part_set = null; } else { this.part_set = tpart_set; this.screen = "parts"; } } } if (Lang13.Bool(href_list["part"])) { T = filter.getStr("part"); foreach (dynamic _a in Lang13.Enumerate(this.files.known_designs)) { v = _a; D = this.files.known_designs[v]; if ((D.build_type & 16) != 0) { if (D.id == T) { if (!this.processing_queue) { this.build_part(D); } else { this.add_to_queue(D); } break; } } } } if (Lang13.Bool(href_list["add_to_queue"])) { T2 = filter.getStr("add_to_queue"); foreach (dynamic _b in Lang13.Enumerate(this.files.known_designs)) { v2 = _b; D2 = this.files.known_designs[v2]; if ((D2.build_type & 16) != 0) { if (D2.id == T2) { this.add_to_queue(D2); break; } } } this.update_queue_on_page(); return(null); } if (Lang13.Bool(href_list["remove_from_queue"])) { this.remove_from_queue(filter.getNum("remove_from_queue")); this.update_queue_on_page(); return(null); } if (Lang13.Bool(href_list["partset_to_queue"])) { this.add_part_set_to_queue(filter.get("partset_to_queue")); this.update_queue_on_page(); return(null); } if (Lang13.Bool(href_list["process_queue"])) { Task13.Schedule(0, (Task13.Closure)(() => { if (this.processing_queue || this.being_built != null) { return; } this.processing_queue = true; this.process_queue(); this.processing_queue = false; return; })); } if (Lang13.Bool(href_list["clear_temp"])) { this.temp = null; } if (Lang13.Bool(href_list["screen"])) { this.screen = href_list["screen"]; } if (Lang13.Bool(href_list["queue_move"]) && Lang13.Bool(href_list["index"])) { index = filter.getNum("index"); new_index = index + filter.getNum("queue_move"); if (Lang13.Bool(Lang13.IsNumber(index)) && Lang13.Bool(Lang13.IsNumber(new_index))) { if (GlobalFuncs.IsInRange(new_index, 1, this.queue.len)) { this.queue.Swap(Convert.ToInt32(index), Convert.ToInt32(new_index)); } } this.update_queue_on_page(); return(null); } if (Lang13.Bool(href_list["clear_queue"])) { this.queue = new ByTable(); this.update_queue_on_page(); return(null); } if (Lang13.Bool(href_list["sync"])) { this.f_sync(); } if (Lang13.Bool(href_list["part_desc"])) { T3 = filter.getStr("part_desc"); foreach (dynamic _c in Lang13.Enumerate(this.files.known_designs)) { v3 = _c; D3 = this.files.known_designs[v3]; if ((D3.build_type & 16) != 0) { if (D3.id == T3) { part = D3.build_path; this.temp = new Txt("<h1>").item(Lang13.Initial(part, "name")).str(" description:</h1>\n ").item(Lang13.Initial(part, "desc")).str("<br>\n <a href='?src=").Ref(this).str(";clear_temp=1'>Return</a>\n ").ToString(); break; } } } } if (Lang13.Bool(href_list["remove_mat"]) && Lang13.Bool(href_list["material"])) { amount = String13.ParseNumber(href_list["remove_mat"]); material = href_list["material"]; if ((amount ?? 0) < 0 || (amount ?? 0) > Convert.ToDouble(this.resources[material])) { return(null); } removed = this.remove_material(material, amount); if (removed == -1) { this.temp = "Not enough " + this.material2name(material) + " to produce a sheet."; } else { this.temp = "Ejected " + removed + " of " + this.material2name(material); } this.temp += new Txt("<br><a href='?src=").Ref(this).str(";clear_temp=1'>Return</a>").ToString(); } this.updateUsrDialog(); return(null); }
// Function from file: autolathe.dm public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null) { Ent_Static T = null; double? multiplier = null; int max_multiplier = 0; dynamic is_stack = null; double coeff = 0; dynamic metal_cost = null; dynamic glass_cost = null; double power = 0; ByTable materials_used = null; dynamic N = null; Obj_Item_Stack S = null; ByTable materials_used2 = null; dynamic new_item = null; dynamic v = null; dynamic D = null; if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc)))) { return(null); } if (!this.busy) { if (Lang13.Bool(href_list["menu"])) { this.screen = String13.ParseNumber(href_list["menu"]); } if (Lang13.Bool(href_list["category"])) { this.selected_category = href_list["category"]; } if (Lang13.Bool(href_list["make"])) { T = this.loc; this.being_built = this.files.FindDesignByID(href_list["make"]); if (!(this.being_built != null)) { return(null); } multiplier = String13.ParseNumber(href_list["multiplier"]); max_multiplier = Num13.MinInt(this.being_built.maxstack, ((int)((Lang13.Bool(this.being_built.materials["$metal"]) ? Num13.Floor((this.materials.amount("$metal") ?1:0) / Convert.ToDouble(this.being_built.materials["$metal"])) : Double.PositiveInfinity))), ((int)((Lang13.Bool(this.being_built.materials["$glass"]) ? Num13.Floor((this.materials.amount("$glass") ?1:0) / Convert.ToDouble(this.being_built.materials["$glass"])) : Double.PositiveInfinity)))); is_stack = this.being_built.build_path.IsSubclassOf(typeof(Obj_Item_Stack)); if (!Lang13.Bool(is_stack) && (multiplier ?? 0) > 1) { return(null); } if (!new ByTable(new object [] { 1, 10, 25, max_multiplier }).Contains(multiplier)) { return(null); } coeff = (Lang13.Bool(is_stack) ? 1 : Math.Pow(2, this.prod_coeff)); metal_cost = this.being_built.materials["$metal"]; glass_cost = this.being_built.materials["$glass"]; power = Num13.MaxInt(2000, Convert.ToInt32((metal_cost + glass_cost) * multiplier / 5)); if ((this.materials.amount("$metal") ?1:0) >= Convert.ToDouble(metal_cost * multiplier / coeff) && (this.materials.amount("$glass") ?1:0) >= Convert.ToDouble(glass_cost * multiplier / coeff)) { this.busy = true; this.f_use_power(power); this.icon_state = "autolathe"; Icon13.Flick("autolathe_n", this); Task13.Schedule(((int)(32 / coeff)), (Task13.Closure)(() => { this.f_use_power(power); if (Lang13.Bool(is_stack)) { materials_used = new ByTable().Set("$metal", metal_cost * multiplier).Set("$glass", glass_cost * multiplier); this.materials.use_amount(materials_used); N = Lang13.Call(this.being_built.build_path, T, multiplier); N.update_icon(); ((Obj_Item)N).autolathe_crafted(this); foreach (dynamic _a in Lang13.Enumerate(T.contents - N, typeof(Obj_Item_Stack))) { S = _a; if (Lang13.Bool(((dynamic)N.merge_type).IsInstanceOfType(S))) { N.merge(S); } } } else { materials_used2 = new ByTable().Set("$metal", metal_cost / coeff).Set("$glass", glass_cost / coeff); this.materials.use_amount(materials_used2); new_item = Lang13.Call(this.being_built.build_path, T); new_item.materials = materials_used2.Copy(); ((Obj_Item)new_item).autolathe_crafted(this); } this.busy = false; this.updateUsrDialog(); return; })); } } if (Lang13.Bool(href_list["search"])) { this.matching_designs.Cut(); foreach (dynamic _b in Lang13.Enumerate(this.files.known_designs)) { v = _b; D = this.files.known_designs[v]; if (String13.FindIgnoreCase(D.name, href_list["to_search"], 1, 0) != 0) { this.matching_designs.Add(D); } } } } else { Task13.User.WriteMsg("<span class=\"alert\">The autolathe is busy. Please wait for completion of previous operation.</span>"); } this.updateUsrDialog(); return(null); }