// Function from file: bags.dm
        public override bool can_be_inserted(dynamic W = null, bool?stop_messages = null, dynamic user = null)
        {
            stop_messages = stop_messages ?? false;

            double current         = 0;
            Obj_Item_Stack_Sheet S = null;


            if (!(W is Obj_Item_Stack_Sheet) || W is Obj_Item_Stack_Sheet_Mineral_Sandstone || W is Obj_Item_Stack_Sheet_Mineral_Wood)
            {
                if (!(stop_messages == true))
                {
                    Task13.User.WriteMsg("The snatcher does not accept " + W + ".");
                }
                return(false);
            }
            current = 0;

            foreach (dynamic _a in Lang13.Enumerate(this.contents, typeof(Obj_Item_Stack_Sheet)))
            {
                S = _a;

                current += S.amount ?? 0;
            }

            if (this.capacity == current)
            {
                if (!(stop_messages == true))
                {
                    Task13.User.WriteMsg("<span class='danger'>The snatcher is full.</span>");
                }
                return(false);
            }
            return(true);
        }
        // Function from file: machine_stacking.dm
        public virtual void process_sheet(Obj_Item_Stack_Sheet inp = null)
        {
            dynamic s       = null;
            dynamic storage = null;
            dynamic _out    = null;


            if (!this.stack_list.Contains(inp.type))
            {
                s        = Lang13.Call(inp.type, this, 0);
                s.amount = 0;
                this.stack_list[inp.type] = s;
            }
            storage         = this.stack_list[inp.type];
            storage.amount += inp.amount;
            inp.loc         = null;

            while (Convert.ToDouble(storage.amount) > this.stack_amt)
            {
                _out        = Lang13.Call(inp.type);
                _out.amount = this.stack_amt;
                this.unload_mineral(_out);
                storage.amount -= this.stack_amt;
            }
            return;
        }
        // Function from file: machine_stacking.dm
        public override int?process(dynamic seconds = null)
        {
            Tile T = null;
            Obj_Item_Stack_Sheet S = null;

            T = Map13.GetStep(this, this.input_dir);

            if (T != null)
            {
                foreach (dynamic _a in Lang13.Enumerate(T, typeof(Obj_Item_Stack_Sheet)))
                {
                    S = _a;

                    this.process_sheet(S);
                }
            }
            return(null);
        }
        // Function from file: laborstacker.dm
        public override void process_sheet(Obj_Item_Stack_Sheet inp = null)
        {
            string n = null;
            double?a = null;


            if (inp is Obj_Item_Stack_Sheet)
            {
                n = inp.name;
                a = inp.amount;

                if (this.ore_values.Contains(n))
                {
                    this.points += Convert.ToDouble(this.ore_values[n] * a);
                }
            }
            base.process_sheet(inp);
            return;
        }
        // Function from file: runes.dm
        public override void invoke(dynamic user = null)
        {
            dynamic T = null;
            Obj_Item_Stack_Sheet S = null;
            Obj_Item_Stack_Sheet M = null;

            T = GlobalFuncs.get_turf(this);

            foreach (dynamic _a in Lang13.Enumerate(T, typeof(Obj_Item_Stack_Sheet)))
            {
                S = _a;


                if (S is Obj_Item_Stack_Sheet_Plasteel)
                {
                    M = S;

                    if ((M.amount ?? 0) >= 5)
                    {
                        ((Ent_Dynamic)user).say("Ethra p'ni dedol!");
                        new Obj_Structure_Constructshell(T);
                        M.visible_message("<span class='warning'>" + M + " bends and twists into a humanoid shell!</span>");
                        M.amount -= 5;

                        if ((M.amount ?? 0) <= 0)
                        {
                            GlobalFuncs.qdel(M);
                        }
                        GlobalFuncs.qdel(this);
                        return;
                    }
                    else
                    {
                        user.WriteMsg("<span class='cultitalic'>There must be at least five sheets of plasteel on " + this + "!</span>");
                        this.fail_invoke();
                        GlobalFuncs.log_game("Construct Shell rune failed - not enough plasteel sheets");
                        return;
                    }
                }
            }
            return;
        }
        // Function from file: bags.dm
        public override void orient2hud(dynamic user = null)
        {
            int     adjusted_contents = 0;
            ByTable numbered_contents = null;
            Obj_Item_Stack_Sheet I    = null;
            NumberedDisplay      D    = null;
            int row_num   = 0;
            int col_count = 0;

            adjusted_contents = this.contents.len;

            if (this.display_contents_with_number)
            {
                numbered_contents = new ByTable();
                adjusted_contents = 0;

                foreach (dynamic _a in Lang13.Enumerate(this.contents, typeof(Obj_Item_Stack_Sheet)))
                {
                    I = _a;

                    adjusted_contents++;
                    D        = new NumberedDisplay(I);
                    D.number = I.amount;
                    numbered_contents.Add(D);
                }
            }
            row_num   = 0;
            col_count = Num13.MinInt(7, ((int)(this.storage_slots ?? 0))) - 1;

            if (adjusted_contents > 7)
            {
                row_num = Num13.Floor((adjusted_contents - 1) / 7);
            }
            this.standard_orient_objs(row_num, col_count, numbered_contents);
            return;
        }
        public override void quick_empty(  )
        {
            dynamic location       = null;
            Obj_Item_Stack_Sheet S = null;
            dynamic N         = null;
            int     stacksize = 0;

            location = GlobalFuncs.get_turf(this);

            foreach (dynamic _a in Lang13.Enumerate(this.contents, typeof(Obj_Item_Stack_Sheet)))
            {
                S = _a;


                while (Lang13.Bool(S.amount))
                {
                    N         = Lang13.Call(S.type, location);
                    stacksize = Num13.MinInt(((int)(S.amount ?? 0)), Convert.ToInt32(N.max_amount));
                    N.amount  = stacksize;
                    S.amount -= stacksize;
                }

                if (!Lang13.Bool(S.amount))
                {
                    GlobalFuncs.qdel(S);
                }
            }
            this.orient2hud(Task13.User);

            if (Task13.User.s_active != null)
            {
                Task13.User.s_active.show_to(Task13.User);
            }
            this.update_icon();
            return;
        }
		// 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;
		}
        // Function from file: bags.dm
        public override bool handle_item_insertion(dynamic W = null, bool?prevent_warning = null, dynamic user = null)
        {
            prevent_warning = prevent_warning ?? false;

            dynamic S                  = null;
            double  amount             = 0;
            bool    inserted           = false;
            double  current            = 0;
            Obj_Item_Stack_Sheet S2    = null;
            Obj_Item_Stack_Sheet sheet = null;

            S = W;

            if (!(S is Obj_Item_Stack_Sheet))
            {
                return(false);
            }
            inserted = false;
            current  = 0;

            foreach (dynamic _a in Lang13.Enumerate(this.contents, typeof(Obj_Item_Stack_Sheet)))
            {
                S2 = _a;

                current += S2.amount ?? 0;
            }

            if (this.capacity < current + Convert.ToDouble(S.amount))
            {
                amount = this.capacity - current;
            }
            else
            {
                amount = Convert.ToDouble(S.amount);
            }

            foreach (dynamic _b in Lang13.Enumerate(this.contents, typeof(Obj_Item_Stack_Sheet)))
            {
                sheet = _b;


                if (S.type == sheet.type)
                {
                    sheet.amount += amount;
                    S.amount     -= amount;
                    inserted      = true;
                    break;
                }
            }

            if (!inserted || !Lang13.Bool(S.amount))
            {
                Task13.User.unEquip(S);

                if (Task13.User.client != null && Task13.User.s_active != this)
                {
                    Task13.User.client.screen.Remove(S);
                }
                ((Obj_Item)S).dropped(Task13.User);

                if (!Lang13.Bool(S.amount))
                {
                    GlobalFuncs.qdel(S);
                }
                else
                {
                    S.loc = this;
                }
            }
            this.orient2hud(Task13.User);

            if (Task13.User.s_active != null)
            {
                Task13.User.s_active.show_to(Task13.User);
            }
            this.update_icon();
            return(true);
        }
        // Function from file: mint.dm
        public override int?process(dynamic seconds = null)
        {
            Tile T = null;
            Obj_Item_Stack_Sheet O = null;

            T = Map13.GetStep(this, this.input_dir);

            if (T != null)
            {
                foreach (dynamic _a in Lang13.Enumerate(T, typeof(Obj_Item_Stack_Sheet)))
                {
                    O = _a;


                    if (O is Obj_Item_Stack_Sheet_Mineral_Gold)
                    {
                        this.amt_gold += (O.amount ?? 0) * 100;
                        O.loc          = null;
                    }

                    if (O is Obj_Item_Stack_Sheet_Mineral_Silver)
                    {
                        this.amt_silver += (O.amount ?? 0) * 100;
                        O.loc            = null;
                    }

                    if (O is Obj_Item_Stack_Sheet_Mineral_Diamond)
                    {
                        this.amt_diamond += (O.amount ?? 0) * 100;
                        O.loc             = null;
                    }

                    if (O is Obj_Item_Stack_Sheet_Mineral_Plasma)
                    {
                        this.amt_plasma += (O.amount ?? 0) * 100;
                        O.loc            = null;
                    }

                    if (O is Obj_Item_Stack_Sheet_Mineral_Uranium)
                    {
                        this.amt_uranium += (O.amount ?? 0) * 100;
                        O.loc             = null;
                    }

                    if (O is Obj_Item_Stack_Sheet_Metal)
                    {
                        this.amt_iron += (O.amount ?? 0) * 100;
                        O.loc          = null;
                    }

                    if (O is Obj_Item_Stack_Sheet_Mineral_Bananium)
                    {
                        this.amt_clown += (O.amount ?? 0) * 100;
                        O.loc           = null;
                    }

                    if (O is Obj_Item_Stack_Sheet_Mineral_Adamantine)
                    {
                        this.amt_adamantine += (O.amount ?? 0) * 100;
                        O.loc = null;
                    }
                    return(null);
                }
            }
            return(null);
        }