Example #1
0
        // Function from file: buildmode.dm
        public bool ClickOn(Ent_Static user = null, string _params = null, Base_Data _object = null)
        {
            bool _default = false;

            ByTable   pa          = null;
            int       right_click = 0;
            int       left_click  = 0;
            int       alt_click   = 0;
            int       ctrl_click  = 0;
            Base_Data T           = null;
            Base_Data T2          = null;
            Base_Data T3          = null;
            Base_Data T4          = null;
            Obj_Structure_Window_Reinforced WIN  = null;
            Obj_Structure_Window_Reinforced WIN2 = null;
            Obj_Structure_Window_Reinforced WIN3 = null;
            Obj_Structure_Window_Reinforced WIN4 = null;
            Obj_Structure_Window_Reinforced WIN5 = null;
            dynamic T5 = null;
            dynamic A  = null;
            dynamic G  = null;
            dynamic T6 = null;

            pa          = String13.ParseUrlParams(_params);
            right_click = pa.Find("right");
            left_click  = pa.Find("left");
            alt_click   = pa.Find("alt");
            ctrl_click  = pa.Find("ctrl");
            _default    = true;

            switch ((int)(this.mode))
            {
            case 1:

                if (_object is Tile && left_click != 0 && !(alt_click != 0) && !(ctrl_click != 0))
                {
                    T = _object;

                    if (_object is Tile_Space)
                    {
                        ((Tile)T).ChangeTurf(typeof(Tile_Simulated_Floor_Plasteel));
                    }
                    else if (_object is Tile_Simulated_Floor)
                    {
                        ((Tile)T).ChangeTurf(typeof(Tile_Simulated_Wall));
                    }
                    else if (_object is Tile_Simulated_Wall)
                    {
                        ((Tile)T).ChangeTurf(typeof(Tile_Simulated_Wall_RWall));
                    }
                    GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " built " + T + " at (" + ((dynamic)T).x + "," + ((dynamic)T).y + "," + ((dynamic)T).z + ")");
                    return(_default);
                }
                else if (right_click != 0)
                {
                    GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " deleted " + _object + " at (" + ((dynamic)_object).x + "," + ((dynamic)_object).y + "," + ((dynamic)_object).z + ")");

                    if (_object is Tile_Simulated_Wall)
                    {
                        T2 = _object;
                        ((Tile)T2).ChangeTurf(typeof(Tile_Simulated_Floor_Plasteel));
                    }
                    else if (_object is Tile_Simulated_Floor)
                    {
                        T3 = _object;
                        ((Tile)T3).ChangeTurf(typeof(Tile_Space));
                    }
                    else if (_object is Tile_Simulated_Wall_RWall)
                    {
                        T4 = _object;
                        ((Tile)T4).ChangeTurf(typeof(Tile_Simulated_Wall));
                    }
                    else if (_object is Obj)
                    {
                        GlobalFuncs.qdel(_object);
                    }
                    return(_default);
                }
                else if (_object is Tile && alt_click != 0 && left_click != 0)
                {
                    GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " built an airlock at (" + ((dynamic)_object).x + "," + ((dynamic)_object).y + "," + ((dynamic)_object).z + ")");
                    new Obj_Machinery_Door_Airlock(GlobalFuncs.get_turf(_object));
                }
                else if (_object is Tile && ctrl_click != 0 && left_click != 0)
                {
                    switch ((int?)(this.build_dir))
                    {
                    case 1:
                        WIN     = new Obj_Structure_Window_Reinforced(GlobalFuncs.get_turf(_object));
                        WIN.dir = ((int)(GlobalVars.NORTH));
                        break;

                    case 2:
                        WIN2     = new Obj_Structure_Window_Reinforced(GlobalFuncs.get_turf(_object));
                        WIN2.dir = ((int)(GlobalVars.SOUTH));
                        break;

                    case 4:
                        WIN3     = new Obj_Structure_Window_Reinforced(GlobalFuncs.get_turf(_object));
                        WIN3.dir = ((int)(GlobalVars.EAST));
                        break;

                    case 8:
                        WIN4     = new Obj_Structure_Window_Reinforced(GlobalFuncs.get_turf(_object));
                        WIN4.dir = ((int)(GlobalVars.WEST));
                        break;

                    case 9:
                        WIN5     = new Obj_Structure_Window_Reinforced(GlobalFuncs.get_turf(_object));
                        WIN5.dir = ((int)(GlobalVars.NORTHWEST));
                        break;
                    }
                    GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " built a window at (" + ((dynamic)_object).x + "," + ((dynamic)_object).y + "," + ((dynamic)_object).z + ")");
                }
                break;

            case 2:

                if (left_click != 0)
                {
                    if (Lang13.Bool(this.objholder.IsSubclassOf(typeof(Tile))))
                    {
                        T5 = GlobalFuncs.get_turf(_object);
                        GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " modified " + T5 + " (" + T5.x + "," + T5.y + "," + T5.z + ") to " + this.objholder);
                        ((Tile)T5).ChangeTurf(this.objholder);
                    }
                    else
                    {
                        A     = Lang13.Call(this.objholder, GlobalFuncs.get_turf(_object));
                        A.dir = this.build_dir;
                        GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " modified " + A + "'s (" + A.x + "," + A.y + "," + A.z + ") dir to " + this.build_dir);
                    }
                }
                else if (right_click != 0)
                {
                    if (_object is Obj)
                    {
                        GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " deleted " + _object + " at (" + ((dynamic)_object).x + "," + ((dynamic)_object).y + "," + ((dynamic)_object).z + ")");
                        GlobalFuncs.qdel(_object);
                    }
                }
                break;

            case 3:

                if (left_click != 0)
                {
                    if (_object.vars.Find(this.varholder) != 0)
                    {
                        GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " modified " + ((dynamic)_object).name + "'s " + this.varholder + " to " + this.valueholder);
                        _object.vars[this.varholder] = this.valueholder;
                    }
                    else
                    {
                        ((dynamic)user).WriteMsg("<span class='warning'>" + Lang13.Initial(_object, "name") + " does not have a var called '" + this.varholder + "'</span>");
                    }
                }

                if (right_click != 0)
                {
                    if (_object.vars.Find(this.varholder) != 0)
                    {
                        GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " modified " + ((dynamic)_object).name + "'s " + this.varholder + " to " + this.valueholder);
                        _object.vars[this.varholder] = Lang13.Initial(_object, this.varholder);
                    }
                    else
                    {
                        ((dynamic)user).WriteMsg("<span class='warning'>" + Lang13.Initial(_object, "name") + " does not have a var called '" + this.varholder + "'</span>");
                    }
                }
                break;

            case 4:

                if (left_click != 0)
                {
                    if (_object is Tile)
                    {
                        return(_default);
                    }
                    this.throw_atom = _object;
                }

                if (right_click != 0)
                {
                    if (this.throw_atom != null)
                    {
                        ((Ent_Dynamic)this.throw_atom).throw_at(_object, 10, 1, user);
                        GlobalFuncs.log_admin("Build Mode: " + GlobalFuncs.key_name(user) + " threw " + this.throw_atom + " at " + _object + " (" + ((dynamic)_object).x + "," + ((dynamic)_object).y + "," + ((dynamic)_object).z + ")");
                    }
                }
                break;

            case 5:

                if (!Lang13.Bool(this.cornerA))
                {
                    this.cornerA = GlobalFuncs.get_turf(_object);
                    return(_default);
                }

                if (Lang13.Bool(this.cornerA) && !Lang13.Bool(this.cornerB))
                {
                    this.cornerB = GlobalFuncs.get_turf(_object);
                }

                if (left_click != 0)
                {
                    if (Lang13.Bool(this.cornerA) && Lang13.Bool(this.cornerB))
                    {
                        if (!Lang13.Bool(this.generator_path))
                        {
                            ((dynamic)user).WriteMsg("<span class='warning'>Select generator type first.</span>");
                        }
                        G = Lang13.Call(this.generator_path);
                        ((MapGenerator)G).defineRegion(this.cornerA, this.cornerB, true);
                        ((MapGenerator)G).generate();
                        this.cornerA = null;
                        this.cornerB = null;
                        return(_default);
                    }
                }
                this.cornerA = null;
                this.cornerB = null;
                break;

            case 6:

                if (left_click != 0)
                {
                    T6 = GlobalFuncs.get_turf(_object);

                    if (this.stored != null)
                    {
                        GlobalFuncs.DuplicateObject(this.stored, true, null, T6);
                    }
                }
                else if (right_click != 0)
                {
                    if (_object is Ent_Dynamic)
                    {
                        this.stored = _object;
                    }
                }
                break;
            }
            return(_default);
        }
Example #2
0
        // Function from file: area_copy.dm
        public dynamic copy_contents_to(dynamic A = null, bool?platingRequired = null, bool?nerf_weapons = null)
        {
            platingRequired = platingRequired ?? false;
            nerf_weapons    = nerf_weapons ?? false;

            ByTable        turfs_src       = null;
            ByTable        turfs_trg       = null;
            int            src_min_x       = 0;
            int            src_min_y       = 0;
            ByTable        refined_src     = null;
            dynamic        T               = null;
            dynamic        T2              = null;
            int            trg_min_x       = 0;
            int            trg_min_y       = 0;
            ByTable        refined_trg     = null;
            dynamic        T3              = null;
            dynamic        T4              = null;
            ByTable        toupdate        = null;
            ByTable        copiedobjs      = null;
            Tile_Simulated T5              = null;
            dynamic        coordstring     = null;
            dynamic        B               = null;
            int            old_dir1        = 0;
            string         old_icon_state1 = null;
            string         old_icon1       = null;
            dynamic        X               = null;
            Obj            O               = null;
            dynamic        O2              = null;
            dynamic        M               = null;
            dynamic        SM              = null;
            dynamic        V               = null;
            Tile_Simulated T1              = null;


            if (!Lang13.Bool(A) || !(this != null))
            {
                return(0);
            }
            turfs_src   = GlobalFuncs.get_area_turfs(this.type);
            turfs_trg   = GlobalFuncs.get_area_turfs(A.type);
            src_min_x   = 99999;
            src_min_y   = 99999;
            refined_src = new ByTable();

            foreach (dynamic _a in Lang13.Enumerate(turfs_src))
            {
                T = _a;

                src_min_x = Num13.MinInt(src_min_x, Convert.ToInt32(T.x));
                src_min_y = Num13.MinInt(src_min_y, Convert.ToInt32(T.y));
            }

            foreach (dynamic _b in Lang13.Enumerate(turfs_src))
            {
                T2 = _b;

                refined_src[T2] = "" + (T2.x - src_min_x) + "." + (T2.y - src_min_y);
            }
            trg_min_x   = 99999;
            trg_min_y   = 99999;
            refined_trg = new ByTable();

            foreach (dynamic _c in Lang13.Enumerate(turfs_trg))
            {
                T3 = _c;

                trg_min_x = Num13.MinInt(trg_min_x, Convert.ToInt32(T3.x));
                trg_min_y = Num13.MinInt(trg_min_y, Convert.ToInt32(T3.y));
            }

            foreach (dynamic _d in Lang13.Enumerate(turfs_trg))
            {
                T4 = _d;

                refined_trg["" + (T4.x - trg_min_x) + "." + (T4.y - trg_min_y)] = T4;
            }
            toupdate   = new ByTable();
            copiedobjs = new ByTable();

            foreach (dynamic _h in Lang13.Enumerate(refined_src, typeof(Tile_Simulated)))
            {
                T5 = _h;

                coordstring = refined_src[T5];
                B           = refined_trg[coordstring];

                if (!(B is Tile))
                {
                    continue;
                }

                if (platingRequired == true)
                {
                    if (B is Tile_Space)
                    {
                        continue;
                    }
                }
                old_dir1        = T5.dir;
                old_icon_state1 = T5.icon_state;
                old_icon1       = T5.icon;
                X            = Lang13.Call(T5.type, B);
                X.dir        = old_dir1;
                X.icon       = old_icon1;
                X.icon_state = old_icon_state1;

                foreach (dynamic _e in Lang13.Enumerate(T5, typeof(Obj)))
                {
                    O = _e;

                    O2 = GlobalFuncs.DuplicateObject(O, true, null, X, nerf_weapons);

                    if (!Lang13.Bool(O2))
                    {
                        continue;
                    }
                    copiedobjs.Add(((Ent_Static)O2).GetAllContents());
                }

                foreach (dynamic _f in Lang13.Enumerate(T5))
                {
                    M = _f;


                    if (M is Mob_Camera)
                    {
                        continue;
                    }
                    SM = GlobalFuncs.DuplicateObject(M, true, null, X);
                    copiedobjs.Add(((Ent_Static)SM).GetAllContents());
                }

                foreach (dynamic _g in Lang13.Enumerate(T5.vars - GlobalVars.forbidden_vars))
                {
                    V = _g;


                    if (V == "air")
                    {
                        X.air.copy_from(T5.air);
                        continue;
                    }
                    X.vars[V] = T5.vars[V];
                }
                toupdate.Add(X);
            }

            if (toupdate.len != 0)
            {
                foreach (dynamic _i in Lang13.Enumerate(toupdate, typeof(Tile_Simulated)))
                {
                    T1 = _i;

                    T1.CalculateAdjacentTurfs();
                    GlobalVars.SSair.add_to_active(T1, true);
                }
            }
            return(copiedobjs);
        }