// Function from file: food_cart.dm
 public Obj_Machinery_FoodCart(dynamic loc = null) : base((object)(loc))
 {
     // Warning: Super call was HERE! If anything above HERE is needed by the super call, it might break!;
     this.create_reagents(200);
     this.mixer      = new Obj_Item_Weapon_ReagentContainers(this, 100);
     this.mixer.name = "Mixer";
     return;
 }
        // Function from file: reagent_containers.dm
        public string reagentlist(Obj_Item_Weapon_ReagentContainers snack = null)
        {
            dynamic data = null;
            Reagent R    = null;


            if (snack.reagents.reagent_list != null && snack.reagents.reagent_list.len != 0)
            {
                foreach (dynamic _a in Lang13.Enumerate(snack.reagents.reagent_list, typeof(Reagent)))
                {
                    R = _a;

                    data += "" + R.id + "(" + R.volume + " units); ";
                }
                return(data);
            }
            else
            {
                return("No reagents");
            }
        }
		// Function from file: reagentgrinder.dm
		public void grind(  ) {
			int offset = 0;
			Obj_Item_Weapon_ReagentContainers_Food_Snacks O = null;
			dynamic allowed = null;
			dynamic r_id = null;
			dynamic space = null;
			double amount = 0;
			Obj_Item_Stack_Sheet O2 = null;
			dynamic allowed2 = null;
			double? i = null;
			dynamic r_id2 = null;
			dynamic space2 = null;
			double amount2 = 0;
			Obj_Item_Weapon_Grown O3 = null;
			dynamic allowed3 = null;
			dynamic r_id3 = null;
			dynamic space3 = null;
			bool amount3 = false;
			Obj_Item_Toy_Crayon O4 = null;
			dynamic allowed4 = null;
			dynamic r_id4 = null;
			dynamic space4 = null;
			double amount4 = 0;
			Obj_Item_Weapon_ReagentContainers O5 = null;
			double? amount5 = null;

			this.power_change();

			if ( ( this.stat & 3 ) != 0 ) {
				return;
			}

			if ( !Lang13.Bool( this.beaker ) || Lang13.Bool( this.beaker ) && ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
				return;
			}
			GlobalFuncs.playsound( this.loc, "sound/machines/blender.ogg", 50, 1 );
			offset = ( Rand13.PercentChance( 50 ) ? -2 : 2 );
			Icon13.Animate( new ByTable().Set( 1, this ).Set( "pixel_x", this.pixel_x + offset ).Set( "time", 0.2 ).Set( "loop", 250 ) );
			this.operating = true;
			this.updateUsrDialog();
			Task13.Schedule( 60, (Task13.Closure)(() => {
				this.pixel_x = Convert.ToInt32( Lang13.Initial( this, "pixel_x" ) );
				this.operating = false;
				this.updateUsrDialog();
				return;
			}));

			foreach (dynamic _b in Lang13.Enumerate( this.holdingitems, typeof(Obj_Item_Weapon_ReagentContainers_Food_Snacks) )) {
				O = _b;
				

				if ( ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
					break;
				}
				allowed = this.get_allowed_snack_by_id( O );

				if ( allowed == null ) {
					break;
				}

				foreach (dynamic _a in Lang13.Enumerate( allowed )) {
					r_id = _a;
					
					space = this.beaker.reagents.maximum_volume - this.beaker.reagents.total_volume;
					amount = Convert.ToDouble( allowed[r_id] );

					if ( amount <= 0 ) {
						
						if ( amount == 0 ) {
							
							if ( O.reagents != null && Lang13.Bool( O.reagents.has_reagent( "nutriment" ) ) ) {
								this.beaker.reagents.add_reagent( r_id, Num13.MinInt( O.reagents.get_reagent_amount( "nutriment" ) ?1:0, Convert.ToInt32( space ) ) );
								O.reagents.remove_reagent( "nutriment", Num13.MinInt( O.reagents.get_reagent_amount( "nutriment" ) ?1:0, Convert.ToInt32( space ) ) );
							}
						} else if ( O.reagents != null && Lang13.Bool( O.reagents.has_reagent( "nutriment" ) ) ) {
							this.beaker.reagents.add_reagent( r_id, Num13.MinInt( Num13.Floor( ( O.reagents.get_reagent_amount( "nutriment" ) ?1:0) * Math.Abs( amount ) ), Convert.ToInt32( space ) ) );
							O.reagents.remove_reagent( "nutriment", Num13.MinInt( O.reagents.get_reagent_amount( "nutriment" ) ?1:0, Convert.ToInt32( space ) ) );
						}
					} else {
						O.reagents.trans_id_to( this.beaker, r_id, Num13.MinInt( ((int)( amount )), Convert.ToInt32( space ) ) );
					}

					if ( ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
						break;
					}
				}

				if ( O.reagents.reagent_list.len == 0 ) {
					this.remove_object( O );
				}
			}

			foreach (dynamic _d in Lang13.Enumerate( this.holdingitems, typeof(Obj_Item_Stack_Sheet) )) {
				O2 = _d;
				
				allowed2 = this.get_allowed_by_id( O2 );

				if ( ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
					break;
				}
				i = null;
				i = 1;

				while (( i ??0) <= Num13.Round( O2.amount ??0, 1 )) {
					
					foreach (dynamic _c in Lang13.Enumerate( allowed2 )) {
						r_id2 = _c;
						
						space2 = this.beaker.reagents.maximum_volume - this.beaker.reagents.total_volume;
						amount2 = Convert.ToDouble( allowed2[r_id2] );
						this.beaker.reagents.add_reagent( r_id2, Num13.MinInt( ((int)( amount2 )), Convert.ToInt32( space2 ) ) );

						if ( Convert.ToDouble( space2 ) < amount2 ) {
							break;
						}
					}

					if ( i == Num13.Round( O2.amount ??0, 1 ) ) {
						this.remove_object( O2 );
						break;
					}
					i++;
				}
			}

			foreach (dynamic _f in Lang13.Enumerate( this.holdingitems, typeof(Obj_Item_Weapon_Grown) )) {
				O3 = _f;
				

				if ( ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
					break;
				}
				allowed3 = this.get_allowed_by_id( O3 );

				foreach (dynamic _e in Lang13.Enumerate( allowed3 )) {
					r_id3 = _e;
					
					space3 = this.beaker.reagents.maximum_volume - this.beaker.reagents.total_volume;
					amount3 = Lang13.Bool( allowed3[r_id3] );

					if ( !amount3 ) {
						
						if ( O3.reagents != null && Lang13.Bool( O3.reagents.has_reagent( r_id3 ) ) ) {
							this.beaker.reagents.add_reagent( r_id3, Num13.MinInt( O3.reagents.get_reagent_amount( r_id3 ) ?1:0, Convert.ToInt32( space3 ) ) );
						}
					} else {
						this.beaker.reagents.add_reagent( r_id3, Num13.MinInt( amount3 ?1:0, Convert.ToInt32( space3 ) ) );
					}

					if ( ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
						break;
					}
				}
				this.remove_object( O3 );
			}

			foreach (dynamic _h in Lang13.Enumerate( this.holdingitems, typeof(Obj_Item_Toy_Crayon) )) {
				O4 = _h;
				

				if ( ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
					break;
				}
				allowed4 = this.get_allowed_by_id( O4 );

				foreach (dynamic _g in Lang13.Enumerate( allowed4 )) {
					r_id4 = _g;
					
					space4 = this.beaker.reagents.maximum_volume - this.beaker.reagents.total_volume;
					amount4 = Convert.ToDouble( allowed4[r_id4] );
					this.beaker.reagents.add_reagent( r_id4, Num13.MinInt( ((int)( amount4 )), Convert.ToInt32( space4 ) ) );

					if ( Convert.ToDouble( space4 ) < amount4 ) {
						break;
					}
					this.remove_object( O4 );
				}
			}

			foreach (dynamic _i in Lang13.Enumerate( this.holdingitems, typeof(Obj_Item_Weapon_ReagentContainers) )) {
				O5 = _i;
				

				if ( ( this.beaker.reagents.total_volume ??0) >= Convert.ToDouble( this.beaker.reagents.maximum_volume ) ) {
					break;
				}
				amount5 = O5.reagents.total_volume;
				O5.reagents.trans_to( this.beaker, amount5 );

				if ( !Lang13.Bool( O5.reagents.total_volume ) ) {
					this.remove_object( O5 );
				}
			}
			return;
		}
Exemple #4
0
        // Function from file: chem_master.dm
        public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null)
        {
            string name = null;
            Obj_Item_Weapon_ReagentContainers P = null;
            dynamic R         = null;
            string  dat       = null;
            dynamic T         = null;
            Browser popup     = null;
            string  id        = null;
            double? amount    = null;
            dynamic id2       = null;
            dynamic amt_temp  = null;
            string  id3       = null;
            double? amount2   = null;
            dynamic id4       = null;
            dynamic amt_temp2 = null;
            int?    amount3   = null;
            int     vol_each  = 0;
            string  name2     = null;
            Obj_Item_Weapon_ReagentContainers_Pill P2 = null;
            int?   i     = null;
            string name3 = null;
            Obj_Item_Weapon_ReagentContainers_Food_Condiment_Pack P3 = null;
            int?   amount4   = null;
            int    vol_each2 = 0;
            string name4     = null;
            Obj_Item_Weapon_ReagentContainers_Pill_Patch P4 = null;
            int?i2 = null;


            if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc))))
            {
                return(null);
            }
            Task13.User.set_machine(this);

            if (Lang13.Bool(href_list["ejectp"]))
            {
                if (Lang13.Bool(this.bottle))
                {
                    this.bottle.loc = this.loc;
                    this.bottle     = null;
                }
            }
            else if (Lang13.Bool(href_list["close"]))
            {
                Interface13.Browse(Task13.User, null, "window=chem_master");
                Task13.User.unset_machine();
                return(null);
            }
            else if (Lang13.Bool(href_list["toggle"]))
            {
                this.mode = !this.mode;
            }
            else if (Lang13.Bool(href_list["createbottle"]))
            {
                name = GlobalFuncs.stripped_input(Task13.User, "Name:", "Name your bottle!", (Lang13.Bool(this.reagents.total_volume) ? this.reagents.get_master_reagent_name() : " "), 26);

                if (!Lang13.Bool(name))
                {
                    return(null);
                }

                if (this.condi)
                {
                    P = new Obj_Item_Weapon_ReagentContainers_Food_Condiment(this.loc);
                }
                else
                {
                    P         = new Obj_Item_Weapon_ReagentContainers_Glass_Bottle(this.loc);
                    P.pixel_x = Rand13.Int(-7, 7);
                    P.pixel_y = Rand13.Int(-7, 7);
                }
                P.name = GlobalFuncs.trim("" + name + " bottle");
                this.reagents.trans_to(P, P.volume);
            }

            if (Lang13.Bool(this.beaker))
            {
                if (Lang13.Bool(href_list["analyze"]))
                {
                    if (Lang13.Bool(Lang13.FindObj(href_list["reagent"])))
                    {
                        R = Lang13.FindObj(href_list["reagent"]);

                        if (Lang13.Bool(R))
                        {
                            dat  = "";
                            dat += "<H1>" + (this.condi ? "Condiment" : "Chemical") + " information:</H1>";
                            dat += "<B>Name:</B> " + Lang13.Initial(R, "name") + "<BR><BR>";
                            dat += "<B>State:</B> ";

                            if (Lang13.Initial(R, "reagent_state") == 1)
                            {
                                dat += "Solid";
                            }
                            else if (Lang13.Initial(R, "reagent_state") == 2)
                            {
                                dat += "Liquid";
                            }
                            else if (Lang13.Initial(R, "reagent_state") == 3)
                            {
                                dat += "Gas";
                            }
                            else
                            {
                                dat += "Unknown";
                            }
                            dat  += "<BR>";
                            dat  += "<B>Color:</B> <span style='color:" + Lang13.Initial(R, "color") + ";background-color:" + Lang13.Initial(R, "color") + ";font:Lucida Console'>" + Lang13.Initial(R, "color") + "</span><BR><BR>";
                            dat  += "<B>Description:</B> " + Lang13.Initial(R, "description") + "<BR><BR>";
                            T     = Lang13.Initial(R, "metabolization_rate") * 20;
                            dat  += "<B>Metabolization Rate:</B> " + T + "u/minute<BR>";
                            dat  += "<B>Overdose Threshold:</B> " + (Lang13.Bool(Lang13.Initial(R, "overdose_threshold")) ? "" + Lang13.Initial(R, "overdose_threshold") + "u" : "none") + "<BR>";
                            dat  += "<B>Addiction Threshold:</B> " + (Lang13.Bool(Lang13.Initial(R, "addiction_threshold")) ? "" + Lang13.Initial(R, "addiction_threshold") + "u" : "none") + "<BR><BR>";
                            dat  += new Txt("<BR><A href='?src=").Ref(this).str(";main=1'>Back</A>").ToString();
                            popup = new Browser(Task13.User, "chem_master", this.name);
                            popup.set_content(dat);
                            popup.set_title_image(Task13.User.browse_rsc_icon(this.icon, this.icon_state));
                            popup.open(true);
                            return(null);
                        }
                    }
                }
                else if (Lang13.Bool(href_list["main"]))
                {
                    this.attack_hand(Task13.User);
                    return(null);
                }
                else if (Lang13.Bool(href_list["add"]))
                {
                    if (Lang13.Bool(href_list["amount"]))
                    {
                        id     = href_list["add"];
                        amount = String13.ParseNumber(href_list["amount"]);

                        if ((amount ?? 0) > 0)
                        {
                            ((Reagents)this.beaker.reagents).trans_id_to(this, id, amount);
                        }
                    }
                }
                else if (Lang13.Bool(href_list["addcustom"]))
                {
                    id2      = href_list["addcustom"];
                    amt_temp = this.isgoodnumber(Interface13.Input(Task13.User, "Select the amount to transfer.", "Transfer how much?", this.useramount, null, InputType.Num | InputType.Null));

                    if (!Lang13.Bool(amt_temp))
                    {
                        return(null);
                    }
                    this.useramount = amt_temp;
                    this.Topic(null, new ByTable().Set("amount", "" + this.useramount).Set("add", "" + id2));
                }
                else if (Lang13.Bool(href_list["remove"]))
                {
                    if (Lang13.Bool(href_list["amount"]))
                    {
                        id3     = href_list["remove"];
                        amount2 = String13.ParseNumber(href_list["amount"]);

                        if ((amount2 ?? 0) > 0)
                        {
                            if (this.mode)
                            {
                                this.reagents.trans_id_to(this.beaker, id3, amount2);
                            }
                            else
                            {
                                this.reagents.remove_reagent(id3, amount2);
                            }
                        }
                    }
                }
                else if (Lang13.Bool(href_list["removecustom"]))
                {
                    id4       = href_list["removecustom"];
                    amt_temp2 = this.isgoodnumber(Interface13.Input(Task13.User, "Select the amount to transfer.", "Transfer how much?", this.useramount, null, InputType.Num | InputType.Null));

                    if (!Lang13.Bool(amt_temp2))
                    {
                        return(null);
                    }
                    this.useramount = amt_temp2;
                    this.Topic(null, new ByTable().Set("amount", "" + this.useramount).Set("remove", "" + id4));
                }
                else if (Lang13.Bool(href_list["eject"]))
                {
                    if (Lang13.Bool(this.beaker))
                    {
                        this.beaker.loc = this.loc;
                        this.beaker     = null;
                        this.reagents.clear_reagents();
                        this.icon_state = "mixer0";
                    }
                }
                else if (Lang13.Bool(href_list["createpill"]))
                {
                    if (this.reagents.total_volume == 0)
                    {
                        return(null);
                    }

                    if (!this.condi)
                    {
                        amount3  = 1;
                        vol_each = Num13.MinInt(((int)(this.reagents.total_volume ?? 0)), 50);

                        if (Lang13.Bool(String13.ParseNumber(href_list["many"])))
                        {
                            amount3 = Num13.MinInt(Num13.MaxInt(Num13.Floor(Convert.ToDouble(Interface13.Input(Task13.User, "Max 10. Buffer content will be split evenly.", "How many pills?", amount3, null, InputType.Num | InputType.Null))), 0), 10);

                            if (!Lang13.Bool(amount3))
                            {
                                return(null);
                            }
                            vol_each = Num13.MinInt(((int)((this.reagents.total_volume ?? 0) / (amount3 ?? 0))), 50);
                        }
                        name2 = GlobalFuncs.stripped_input(Task13.User, "Name:", "Name your pill!", "" + this.reagents.get_master_reagent_name() + " (" + vol_each + "u)", 26);

                        if (!Lang13.Bool(name2) || !Lang13.Bool(this.reagents.total_volume))
                        {
                            return(null);
                        }
                        i = null;
                        i = 0;

                        while ((i ?? 0) < (amount3 ?? 0))
                        {
                            if (Lang13.Bool(this.bottle) && this.bottle.contents.len < (this.bottle.storage_slots ?? 0))
                            {
                                P2 = new Obj_Item_Weapon_ReagentContainers_Pill(this.bottle);
                            }
                            else
                            {
                                P2 = new Obj_Item_Weapon_ReagentContainers_Pill(this.loc);
                            }
                            P2.name    = GlobalFuncs.trim("" + name2 + " pill");
                            P2.pixel_x = Rand13.Int(-7, 7);
                            P2.pixel_y = Rand13.Int(-7, 7);
                            this.reagents.trans_to(P2, vol_each);
                            i++;
                        }
                    }
                    else
                    {
                        name3 = GlobalFuncs.stripped_input(Task13.User, "Name:", "Name your pack!", this.reagents.get_master_reagent_name(), 26);

                        if (!Lang13.Bool(name3) || !Lang13.Bool(this.reagents.total_volume))
                        {
                            return(null);
                        }
                        P3 = new Obj_Item_Weapon_ReagentContainers_Food_Condiment_Pack(this.loc);
                        P3.originalname = name3;
                        P3.name         = GlobalFuncs.trim("" + name3 + " pack");
                        P3.desc         = "A small condiment pack. The label says it contains " + name3 + ".";
                        this.reagents.trans_to(P3, 10);
                    }
                }
                else if (Lang13.Bool(href_list["createpatch"]))
                {
                    if (this.reagents.total_volume == 0)
                    {
                        return(null);
                    }
                    amount4   = 1;
                    vol_each2 = Num13.MinInt(((int)(this.reagents.total_volume ?? 0)), 50);

                    if (Lang13.Bool(String13.ParseNumber(href_list["many"])))
                    {
                        amount4 = Num13.MinInt(Num13.MaxInt(Num13.Floor(Convert.ToDouble(Interface13.Input(Task13.User, "Max 10. Buffer content will be split evenly.", "How many patches?", amount4, null, InputType.Num | InputType.Null))), 0), 10);

                        if (!Lang13.Bool(amount4))
                        {
                            return(null);
                        }
                        vol_each2 = Num13.MinInt(((int)((this.reagents.total_volume ?? 0) / (amount4 ?? 0))), 50);
                    }
                    name4 = GlobalFuncs.stripped_input(Task13.User, "Name:", "Name your patch!", "" + this.reagents.get_master_reagent_name() + " (" + vol_each2 + "u)", 26);

                    if (!Lang13.Bool(name4) || !Lang13.Bool(this.reagents.total_volume))
                    {
                        return(null);
                    }
                    P4 = null;
                    i2 = null;
                    i2 = 0;

                    while ((i2 ?? 0) < (amount4 ?? 0))
                    {
                        P4         = new Obj_Item_Weapon_ReagentContainers_Pill_Patch(this.loc);
                        P4.name    = GlobalFuncs.trim("" + name4 + " patch");
                        P4.pixel_x = Rand13.Int(-7, 7);
                        P4.pixel_y = Rand13.Int(-7, 7);
                        this.reagents.trans_to(P4, vol_each2);
                        i2++;
                    }
                }
            }
            this.updateUsrDialog();
            return(null);
        }