예제 #1
0
파일: Reagents.cs 프로젝트: Somnium13/SS13
        // Function from file: holder.dm
        public double?trans_id_to(dynamic target = null, dynamic reagent = null, double?amount = null, bool?preserve_data = null)
        {
            amount        = amount ?? 1;
            preserve_data = preserve_data ?? true;

            Reagents R               = null;
            dynamic  trans_data      = null;
            Reagent  current_reagent = null;


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

            if (!Lang13.Bool(target.reagents) || (this.total_volume ?? 0) <= 0 || !this.get_reagent_amount(reagent))
            {
                return(null);
            }
            R = target.reagents;

            if ((this.get_reagent_amount(reagent) ?1:0) < (amount ?? 0))
            {
                amount = this.get_reagent_amount(reagent) ?1:0;
            }
            amount     = Num13.MinInt(((int)(amount ?? 0)), Convert.ToInt32(R.maximum_volume - R.total_volume));
            trans_data = null;

            foreach (dynamic _a in Lang13.Enumerate(this.reagent_list, typeof(Reagent)))
            {
                current_reagent = _a;


                if (current_reagent.id == reagent)
                {
                    if (preserve_data == true)
                    {
                        trans_data = current_reagent.data;
                    }
                    R.add_reagent(current_reagent.id, amount, trans_data, this.chem_temp);
                    this.remove_reagent(current_reagent.id, amount, true);
                    break;
                }
            }
            this.update_total();
            R.update_total();
            R.handle_reactions();
            return(amount);
        }
예제 #2
0
파일: Reagents.cs 프로젝트: Somnium13/SS13
        // Function from file: holder.dm
        public double?copy_to(dynamic target = null, double?amount = null, bool?multiplier = null, bool?preserve_data = null)
        {
            amount        = amount ?? 1;
            multiplier    = multiplier ?? true;
            preserve_data = preserve_data ?? true;

            Reagents R           = null;
            double   part        = 0;
            dynamic  trans_data  = null;
            dynamic  reagent     = null;
            dynamic  T           = null;
            dynamic  copy_amount = null;


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

            if (!Lang13.Bool(target.reagents) || (this.total_volume ?? 0) <= 0)
            {
                return(null);
            }
            R          = target.reagents;
            amount     = Num13.MinInt(Num13.MinInt(((int)(amount ?? 0)), ((int)(this.total_volume ?? 0))), Convert.ToInt32(R.maximum_volume - R.total_volume));
            part       = (amount ?? 0) / (this.total_volume ?? 0);
            trans_data = null;

            foreach (dynamic _a in Lang13.Enumerate(this.reagent_list))
            {
                reagent = _a;

                T           = reagent;
                copy_amount = T.volume * part;

                if (preserve_data == true)
                {
                    trans_data = T.data;
                }
                R.add_reagent(T.id, copy_amount * multiplier, trans_data);
            }
            this.update_total();
            R.update_total();
            R.handle_reactions();
            this.handle_reactions();
            return(amount);
        }