示例#1
0
        // Function from file: vending.dm
        public void malfunction(  )
        {
            Data_VendingProduct R         = null;
            dynamic             dump_path = null;


            foreach (dynamic _a in Lang13.Enumerate(this.product_records, typeof(Data_VendingProduct)))
            {
                R = _a;


                if ((R.amount ?? 0) <= 0)
                {
                    continue;
                }
                dump_path = R.product_path;

                if (!Lang13.Bool(dump_path))
                {
                    continue;
                }

                while ((R.amount ?? 0) > 0)
                {
                    Lang13.Call(dump_path, this.loc);
                    R.amount--;
                }
                continue;
            }
            this.stat      |= 1;
            this.icon_state = "" + Lang13.Initial(this, "icon_state") + "-broken";
            return;
        }
示例#2
0
        // Function from file: vending.dm
        public override bool default_deconstruction_crowbar(dynamic C = null, bool?ignore_panel = null)
        {
            ByTable                       product_list    = null;
            int?                          i               = null;
            Data_VendingProduct           machine_content = null;
            int                           safety          = 0;
            Obj_Item_Weapon_VendingRefill VR              = null;

            product_list = new ByTable(new object [] { this.product_records, this.hidden_records, this.coin_records });
            i            = null;
            i            = 1;

            while ((i ?? 0) <= 3)
            {
                foreach (dynamic _b in Lang13.Enumerate(product_list[i], typeof(Data_VendingProduct)))
                {
                    machine_content = _b;


                    while (machine_content.amount != 0)
                    {
                        safety = 0;

                        foreach (dynamic _a in Lang13.Enumerate(this.component_parts, typeof(Obj_Item_Weapon_VendingRefill)))
                        {
                            VR = _a;

                            safety++;

                            if (Convert.ToDouble(VR.charges[i]) < Convert.ToDouble(VR.init_charges[i]))
                            {
                                VR.charges[i]++;
                                machine_content.amount--;

                                if (!Lang13.Bool(machine_content.amount))
                                {
                                    break;
                                }
                            }
                            else
                            {
                                safety--;
                            }
                        }

                        if (safety <= 0)
                        {
                            break;
                        }
                    }
                }
                i++;
            }
            base.default_deconstruction_crowbar((object)(C), ignore_panel);
            return(false);
        }
示例#3
0
        // Function from file: vending.dm
        public void build_inventory(ByTable productlist = null, bool?hidden = null, bool?req_coin = null, bool?start_empty = null)
        {
            hidden   = hidden ?? false;
            req_coin = req_coin ?? false;

            dynamic             typepath = null;
            bool?               amount   = null;
            dynamic             temp     = null;
            Data_VendingProduct R        = null;


            foreach (dynamic _a in Lang13.Enumerate(productlist))
            {
                typepath = _a;

                amount = Lang13.BoolNullable(productlist[typepath]);

                if (amount == null)
                {
                    amount = false;
                }
                temp           = Lang13.Call(typepath, null);
                R              = new Data_VendingProduct();
                R.product_name = Lang13.Initial(temp, "name");
                R.product_path = typepath;

                if (!(start_empty == true))
                {
                    R.amount = Lang13.IntNullable(amount);
                }
                R.max_amount    = amount;
                R.display_color = Rand13.Pick(new object [] { "red", "blue", "green" });

                if (hidden == true)
                {
                    this.hidden_records.Add(R);
                }
                else if (req_coin == true)
                {
                    this.coin_records.Add(R);
                }
                else
                {
                    this.product_records.Add(R);
                }
            }
            return;
        }
示例#4
0
        // Function from file: vending.dm
        public bool throw_item(  )
        {
            dynamic             throw_item = null;
            dynamic             target     = null;
            Data_VendingProduct R          = null;
            dynamic             dump_path  = null;

            throw_item = null;
            target     = Lang13.FindIn(typeof(Mob_Living), Map13.FetchInView(this, 7));

            if (!Lang13.Bool(target))
            {
                return(false);
            }

            foreach (dynamic _a in Lang13.Enumerate(this.product_records, typeof(Data_VendingProduct)))
            {
                R = _a;


                if ((R.amount ?? 0) <= 0)
                {
                    continue;
                }
                dump_path = R.product_path;

                if (!Lang13.Bool(dump_path))
                {
                    continue;
                }
                R.amount--;
                throw_item = Lang13.Call(dump_path, this.loc);
                break;
            }

            if (!Lang13.Bool(throw_item))
            {
                return(false);
            }
            ((Ent_Dynamic)throw_item).throw_at(target, 16, 3);
            this.visible_message("<span class='danger'>" + this + " launches " + throw_item + " at " + target + "!</span>");
            return(true);
        }
示例#5
0
        // Function from file: vending.dm
        public int refill_inventory(dynamic refill = null, ByTable machine = null, dynamic charge_type = null)
        {
            charge_type = charge_type ?? 1;

            int total      = 0;
            int to_restock = 0;
            Data_VendingProduct machine_content  = null;
            Data_VendingProduct machine_content2 = null;
            dynamic             tmp_charges      = null;
            Data_VendingProduct machine_content3 = null;
            int restock = 0;

            total      = 0;
            to_restock = 0;

            foreach (dynamic _a in Lang13.Enumerate(machine, typeof(Data_VendingProduct)))
            {
                machine_content = _a;


                if (machine_content.amount == 0 && Convert.ToDouble(refill.charges[charge_type]) > 0)
                {
                    machine_content.amount++;
                    refill.charges[charge_type]--;
                    total++;
                }
                to_restock += (machine_content.max_amount == true ?1:0) - (machine_content.amount ?? 0);
            }

            if (to_restock <= Convert.ToDouble(refill.charges[charge_type]))
            {
                foreach (dynamic _b in Lang13.Enumerate(machine, typeof(Data_VendingProduct)))
                {
                    machine_content2 = _b;

                    machine_content2.amount = Lang13.IntNullable(machine_content2.max_amount);
                }
                refill.charges[charge_type] -= to_restock;
                total += to_restock;
            }
            else
            {
                tmp_charges = refill.charges[charge_type];

                foreach (dynamic _c in Lang13.Enumerate(machine, typeof(Data_VendingProduct)))
                {
                    machine_content3 = _c;


                    if (Lang13.Bool(refill.charges[charge_type]) == false)
                    {
                        break;
                    }
                    restock = GlobalFuncs.Ceiling(((machine_content3.max_amount == true ?1:0) - (machine_content3.amount ?? 0)) / to_restock * Convert.ToDouble(tmp_charges));

                    if (restock > Convert.ToDouble(refill.charges[charge_type]))
                    {
                        restock = Convert.ToInt32(refill.charges[charge_type]);
                    }
                    machine_content3.amount     += restock;
                    refill.charges[charge_type] -= restock;
                    total += restock;
                }
            }
            return(total);
        }
示例#6
0
        // Function from file: vending.dm
        public override dynamic attack_hand(dynamic a = null, bool?b = null, bool?c = null)
        {
            string              dat             = null;
            ByTable             display_records = null;
            Data_VendingProduct R     = null;
            dynamic             O     = null;
            dynamic             N     = null;
            Browser             popup = null;

            dat = "";

            if (Lang13.Bool(this.panel_open) && !(a is Mob_Living_Silicon_Ai))
            {
                return(this.wires.interact(a));
            }
            else
            {
                if ((this.stat & 3) != 0)
                {
                    return(null);
                }
                dat += "<h3>Select an item</h3>";
                dat += "<div class='statusDisplay'>";

                if (this.product_records.len == 0)
                {
                    dat += "<font color = 'red'>No product loaded!</font>";
                }
                else
                {
                    display_records = this.product_records;

                    if (this.extended_inventory)
                    {
                        display_records = this.product_records + this.hidden_records;
                    }

                    if (Lang13.Bool(this.coin))
                    {
                        display_records = this.product_records + this.coin_records;
                    }

                    if (Lang13.Bool(this.coin) && this.extended_inventory)
                    {
                        display_records = this.product_records + this.hidden_records + this.coin_records;
                    }
                    dat += "<ul>";

                    foreach (dynamic _a in Lang13.Enumerate(display_records, typeof(Data_VendingProduct)))
                    {
                        R = _a;

                        dat += "<li>";

                        if ((R.amount ?? 0) > 0)
                        {
                            dat += new Txt("<a href='byond://?src=").Ref(this).str(";vend=").Ref(R).str("'>Vend</a> ").ToString();
                        }
                        else
                        {
                            dat += "<span class='linkOff'>Sold out</span> ";
                        }
                        dat += "<font color = '" + R.display_color + "'><b>" + GlobalFuncs.sanitize(R.product_name) + "</b>:</font>";
                        dat += " <b>" + R.amount + "</b>";
                        dat += "</li>";
                    }
                    dat += "</ul>";
                }
                dat += "</div>";

                if (this.premium.len > 0)
                {
                    dat += "<b>Coin slot:</b> ";

                    if (Lang13.Bool(this.coin))
                    {
                        dat += new Txt().item(this.coin).str("&nbsp;&nbsp;<a href='byond://?src=").Ref(this).str(";remove_coin=1'>Remove</a>").ToString();
                    }
                    else
                    {
                        dat += "<i>No coin</i>&nbsp;&nbsp;<span class='linkOff'>Remove</span>";
                    }
                }

                if (this is Obj_Machinery_Vending_Snack)
                {
                    dat += "<h3>Chef's Food Selection</h3>";
                    dat += "<div class='statusDisplay'>";

                    foreach (dynamic _b in Lang13.Enumerate(this.dish_quants))
                    {
                        O = _b;


                        if (Convert.ToDouble(this.dish_quants[O]) > 0)
                        {
                            N    = this.dish_quants[O];
                            dat += new Txt("<a href='byond://?src=").Ref(this).str(";dispense=").item(GlobalFuncs.sanitize(O)).str("'>Dispense</A> ").ToString();
                            dat += "<B>" + GlobalFuncs.capitalize(O) + ": " + N + "</B><br>";
                        }
                    }
                    dat += "</div>";
                }
            }
            ((Mob)a).set_machine(this);

            if (this.seconds_electrified != 0 && !((this.stat & 2) != 0))
            {
                if (this.shock(a, 100))
                {
                    return(null);
                }
            }
            popup = new Browser(a, "vending", this.name);
            popup.set_content(dat);
            popup.set_title_image(((Mob)a).browse_rsc_icon(this.icon, this.icon_state));
            popup.open();
            return(null);
        }