// Function from file: blueprints.dm public dynamic detect_room(dynamic first = null) { ByTable found = null; ByTable pending = null; ByTable border = null; Ent_Static T = null; dynamic dir = null; bool skip = false; Obj_Structure_Window W = null; Obj_Machinery_Door_Window D = null; Tile NT = null; Ent_Static A = null; dynamic V = null; dynamic F = null; dynamic direction = null; Tile U = null; found = new ByTable(); pending = new ByTable(new object [] { first }); border = new ByTable(); while (pending.len != 0) { if (found.len + pending.len > 300) { return(GlobalVars.ROOM_ERR_TOOLARGE); } T = pending[1]; pending.Remove(T); foreach (dynamic _d in Lang13.Enumerate(GlobalVars.cardinal)) { dir = _d; skip = false; foreach (dynamic _a in Lang13.Enumerate(T, typeof(Obj_Structure_Window))) { W = _a; if (dir == W.dir || new ByTable(new object [] { GlobalVars.NORTHEAST, GlobalVars.SOUTHEAST, GlobalVars.NORTHWEST, GlobalVars.SOUTHWEST }).Contains(W.dir)) { skip = true; break; } } if (skip) { continue; } foreach (dynamic _b in Lang13.Enumerate(T, typeof(Obj_Machinery_Door_Window))) { D = _b; if (dir == D.dir) { skip = true; break; } } if (skip) { continue; } NT = Map13.GetStep(T, Convert.ToInt32(dir)); if (!(NT is Tile) || found.Contains(NT) || pending.Contains(NT)) { continue; } switch ((int)(this.check_tile_is_border(NT, dir))) { case 1: pending.Add(NT); break; case 2: A = NT.loc; if (!Lang13.Bool(found[A.name])) { found[A.name] = NT.loc; } break; case 3: border[NT] += dir; break; case 4: return(GlobalVars.ROOM_ERR_SPACE); break; } } found.Add(T); } foreach (dynamic _f in Lang13.Enumerate(border)) { V = _f; F = V; foreach (dynamic _e in Lang13.Enumerate(GlobalVars.cardinal)) { direction = _e; if (direction == border[F]) { continue; } U = Map13.GetStep(F, Convert.ToInt32(direction)); if (border.Contains(U) || found.Contains(U)) { continue; } if (this.check_tile_is_border(U, direction) == GlobalVars.BORDER_2NDTILE) { found.Add(U); } } found.Or(F); } return(found); }
// Function from file: glass.dm public bool construct_window(dynamic user = null) { string title = null; ByTable directions = null; int i = 0; Obj_Structure_Window win = null; dynamic dir_to_set = null; dynamic direction = null; bool found = false; Obj_Structure_Window WT = null; Obj_Structure_Window_Reinforced W = null; Obj_Structure_Window_Reinforced_Fulltile W2 = null; Obj_Structure_WindoorAssembly WA = null; Obj_Machinery_Door_Window W3 = null; Obj_Structure_WindoorAssembly WD = null; if (!Lang13.Bool(user) || !(this != null)) { return(false); } if (!(user.loc is Tile)) { return(false); } if (!((Mob)user).IsAdvancedToolUser()) { user.WriteMsg("<span class='warning'>You don't have the dexterity to do this!</span>"); return(false); } title = "Sheet Reinf. Glass"; title += new Txt(" (").item(this.get_amount()).str(" sheet").s().str(" left)").ToString(); dynamic _g = Interface13.Input(title, "Would you like full tile glass a one direction glass pane or a windoor?", null, null, new ByTable(new object [] { "One Direction", "Full Window", "Windoor", "Cancel" }), InputType.Any); // Was a switch-case, sorry for the mess. if (_g == "One Direction") { if (!(this != null)) { return(true); } if (this.loc != user) { return(true); } directions = new ByTable(GlobalVars.cardinal); i = 0; foreach (dynamic _a in Lang13.Enumerate(user.loc, typeof(Obj_Structure_Window))) { win = _a; i++; if (i >= 4) { user.WriteMsg("<span class='danger'>There are too many windows in this location.</span>"); return(true); } directions.Remove(win.dir); if (!GlobalVars.cardinal.Contains(win.ini_dir)) { user.WriteMsg("<span class='danger'>Can't let you do that.</span>"); return(true); } } dir_to_set = 2; foreach (dynamic _c in Lang13.Enumerate(new ByTable(new object [] { user.dir, Num13.Rotate(user.dir, 90), Num13.Rotate(user.dir, 180), Num13.Rotate(user.dir, 270) }))) { direction = _c; found = false; foreach (dynamic _b in Lang13.Enumerate(user.loc, typeof(Obj_Structure_Window))) { WT = _b; if (WT.dir == direction) { found = true; } } if (!found) { dir_to_set = direction; break; } } W = null; W = new Obj_Structure_Window_Reinforced(user.loc, true); W.state = 0; W.dir = Convert.ToInt32(dir_to_set); W.ini_dir = W.dir; W.anchored = 0; W.add_fingerprint(user); this.use(1); } else if (_g == "Full Window") { if (!(this != null)) { return(true); } if (this.loc != user) { return(true); } if ((this.get_amount() ?? 0) < 2) { user.WriteMsg("<span class='warning'>You need more glass to do that!</span>"); return(true); } if (Lang13.Bool(Lang13.FindIn(typeof(Obj_Structure_Window), user.loc))) { user.WriteMsg("<span class='warning'>There is a window in the way!</span>"); return(true); } W2 = null; W2 = new Obj_Structure_Window_Reinforced_Fulltile(user.loc, true); W2.state = 0; W2.anchored = 0; W2.add_fingerprint(user); this.use(2); } else if (_g == "Windoor") { if (!(this != null) || this.loc != user || !(user.loc is Tile)) { return(true); } foreach (dynamic _d in Lang13.Enumerate(user.loc, typeof(Obj_Structure_WindoorAssembly))) { WA = _d; if (WA.dir == Convert.ToInt32(user.dir)) { user.WriteMsg("<span class='warning'>There is already a windoor assembly in that location!</span>"); return(true); } } foreach (dynamic _e in Lang13.Enumerate(user.loc, typeof(Obj_Machinery_Door_Window))) { W3 = _e; if (W3.dir == Convert.ToInt32(user.dir)) { user.WriteMsg("<span class='warning'>There is already a windoor in that location!</span>"); return(true); } } if ((this.get_amount() ?? 0) < 5) { user.WriteMsg("<span class='warning'>You need more glass to do that!</span>"); return(true); } WD = new Obj_Structure_WindoorAssembly(user.loc); WD.state = "01"; WD.anchored = 0; WD.add_fingerprint(user); this.use(5); dynamic _f = user.dir; // Was a switch-case, sorry for the mess. if (_f == 2) { WD.dir = ((int)(GlobalVars.SOUTH)); WD.ini_dir = GlobalVars.SOUTH; } else if (_f == 4) { WD.dir = ((int)(GlobalVars.EAST)); WD.ini_dir = GlobalVars.EAST; } else if (_f == 8) { WD.dir = ((int)(GlobalVars.WEST)); WD.ini_dir = GlobalVars.WEST; } else { WD.dir = ((int)(GlobalVars.NORTH)); WD.ini_dir = GlobalVars.NORTH; } } else { return(true); } return(false); }
// Function from file: blueprints.dm public int check_tile_is_border(Tile T2 = null, dynamic dir = null) { Obj_Structure_Window W = null; Obj_Machinery_Door_Window D = null; if (T2 is Tile_Space) { return(GlobalVars.BORDER_SPACE); } if (this.get_area_type(T2.loc) != GlobalVars.AREA_SPACE) { return(GlobalVars.BORDER_BETWEEN); } if (T2 is Tile_Simulated_Wall) { return(GlobalVars.BORDER_2NDTILE); } if (!(T2 is Tile_Simulated)) { return(GlobalVars.BORDER_BETWEEN); } foreach (dynamic _a in Lang13.Enumerate(T2, typeof(Obj_Structure_Window))) { W = _a; if (Num13.Rotate(dir, 180) == W.dir) { return(GlobalVars.BORDER_BETWEEN); } if (new ByTable(new object [] { GlobalVars.NORTHEAST, GlobalVars.SOUTHEAST, GlobalVars.NORTHWEST, GlobalVars.SOUTHWEST }).Contains(W.dir)) { return(GlobalVars.BORDER_2NDTILE); } } foreach (dynamic _b in Lang13.Enumerate(T2, typeof(Obj_Machinery_Door_Window))) { D = _b; if (Num13.Rotate(dir, 180) == D.dir) { return(GlobalVars.BORDER_BETWEEN); } } if (Lang13.Bool(Lang13.FindIn(typeof(Obj_Machinery_Door), T2))) { return(GlobalVars.BORDER_2NDTILE); } if (Lang13.Bool(Lang13.FindIn(typeof(Obj_Structure_Falsewall), T2))) { return(GlobalVars.BORDER_2NDTILE); } return(GlobalVars.BORDER_NONE ?1:0); }
// Function from file: windoor_assembly.dm public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null) { dynamic WT = null; Obj_Item_Stack_Sheet_Rglass RG = null; Obj_Item_Stack_Rods R = null; Obj_Machinery_Door_Window WD = null; Obj_Machinery_Door_Window WD2 = null; dynamic P = null; dynamic CC = null; dynamic ae = null; string t = null; Obj_Machinery_Door_Window_Brigdoor windoor = null; Obj_Machinery_Door_Window windoor2 = null; this.add_fingerprint(user); switch ((string)(this.state)) { case "01": if (A is Obj_Item_Weapon_Weldingtool && !Lang13.Bool(this.anchored)) { WT = A; if (((Obj_Item_Weapon_Weldingtool)WT).remove_fuel(0, user)) { ((Ent_Static)user).visible_message("" + user + " disassembles the windoor assembly.", "<span class='notice'>You start to disassemble the windoor assembly...</span>"); GlobalFuncs.playsound(this.loc, "sound/items/welder2.ogg", 50, 1); if (GlobalFuncs.do_after(user, 40 / A.toolspeed, null, this)) { if (!(this != null) || !((Obj_Item_Weapon_Weldingtool)WT).isOn()) { return(null); } user.WriteMsg("<span class='notice'>You disassemble the windoor assembly.</span>"); RG = new Obj_Item_Stack_Sheet_Rglass(GlobalFuncs.get_turf(this), 5); RG.add_fingerprint(user); if (this.secure) { R = new Obj_Item_Stack_Rods(GlobalFuncs.get_turf(this), 4); R.add_fingerprint(user); } GlobalFuncs.qdel(this); } } else { return(null); } } if (A is Obj_Item_Weapon_Wrench && !Lang13.Bool(this.anchored)) { foreach (dynamic _a in Lang13.Enumerate(this.loc, typeof(Obj_Machinery_Door_Window))) { WD = _a; if (WD.dir == this.dir) { user.WriteMsg("<span class='warning'>There is already a windoor in that location!</span>"); return(null); } } GlobalFuncs.playsound(this.loc, "sound/items/ratchet.ogg", 100, 1); ((Ent_Static)user).visible_message("" + user + " secures the windoor assembly to the floor.", "<span class='notice'>You start to secure the windoor assembly to the floor...</span>"); if (GlobalFuncs.do_after(user, 40 / A.toolspeed, null, this)) { if (!(this != null) || Lang13.Bool(this.anchored)) { return(null); } foreach (dynamic _b in Lang13.Enumerate(this.loc, typeof(Obj_Machinery_Door_Window))) { WD2 = _b; if (WD2.dir == this.dir) { user.WriteMsg("<span class='warning'>There is already a windoor in that location!</span>"); return(null); } } user.WriteMsg("<span class='notice'>You secure the windoor assembly.</span>"); this.anchored = 1; if (this.secure) { this.name = "secure anchored windoor assembly"; } else { this.name = "anchored windoor assembly"; } } } else if (A is Obj_Item_Weapon_Wrench && Lang13.Bool(this.anchored)) { GlobalFuncs.playsound(this.loc, "sound/items/ratchet.ogg", 100, 1); ((Ent_Static)user).visible_message("" + user + " unsecures the windoor assembly to the floor.", "<span class='notice'>You start to unsecure the windoor assembly to the floor...</span>"); if (GlobalFuncs.do_after(user, 40 / A.toolspeed, null, this)) { if (!(this != null) || !Lang13.Bool(this.anchored)) { return(null); } user.WriteMsg("<span class='notice'>You unsecure the windoor assembly.</span>"); this.anchored = 0; if (this.secure) { this.name = "secure windoor assembly"; } else { this.name = "windoor assembly"; } } } else if (A is Obj_Item_Stack_Sheet_Plasteel && !this.secure) { P = A; if (Convert.ToDouble(P.amount) < 2) { user.WriteMsg("<span class='warning'>You need more plasteel to do this!</span>"); return(null); } user.WriteMsg("<span class='notice'>You start to reinforce the windoor with plasteel...</span>"); if (GlobalFuncs.do_after(user, 40, null, this)) { if (!(this != null) || this.secure) { return(null); } P.use(2); user.WriteMsg("<span class='notice'>You reinforce the windoor.</span>"); this.secure = true; if (Lang13.Bool(this.anchored)) { this.name = "secure anchored windoor assembly"; } else { this.name = "secure windoor assembly"; } } } else if (A is Obj_Item_Stack_CableCoil && Lang13.Bool(this.anchored)) { ((Ent_Static)user).visible_message("" + user + " wires the windoor assembly.", "<span class='notice'>You start to wire the windoor assembly...</span>"); if (GlobalFuncs.do_after(user, 40, null, this)) { if (!(this != null) || !Lang13.Bool(this.anchored) || this.state != "01") { return(null); } CC = A; if (!Lang13.Bool(CC.use(1))) { user.WriteMsg("<span class='warning'>You need more cable to do this!</span>"); return(null); } user.WriteMsg("<span class='notice'>You wire the windoor.</span>"); this.state = "02"; if (this.secure) { this.name = "secure wired windoor assembly"; } else { this.name = "wired windoor assembly"; } } } else { base.attackby((object)(A), (object)(user), _params, silent, replace_spent); } break; case "02": if (A is Obj_Item_Weapon_Wirecutters) { GlobalFuncs.playsound(this.loc, "sound/items/Wirecutter.ogg", 100, 1); ((Ent_Static)user).visible_message("" + user + " cuts the wires from the airlock assembly.", "<span class='notice'>You start to cut the wires from airlock assembly...</span>"); if (GlobalFuncs.do_after(user, 40 / A.toolspeed, null, this)) { if (!(this != null) || this.state != "02") { return(null); } user.WriteMsg("<span class='notice'>You cut the windoor wires.</span>"); new Obj_Item_Stack_CableCoil(GlobalFuncs.get_turf(user), 1); this.state = "01"; if (this.secure) { this.name = "secure anchored windoor assembly"; } else { this.name = "anchored windoor assembly"; } } } else if (A is Obj_Item_Weapon_Electronics_Airlock) { if (!Lang13.Bool(user.drop_item())) { return(null); } GlobalFuncs.playsound(this.loc, "sound/items/Screwdriver.ogg", 100, 1); ((Ent_Static)user).visible_message("" + user + " installs the electronics into the airlock assembly.", "<span class='notice'>You start to install electronics into the airlock assembly...</span>"); A.loc = this; if (GlobalFuncs.do_after(user, 40, null, this)) { if (!(this != null) || Lang13.Bool(this.electronics)) { A.loc = this.loc; return(null); } user.WriteMsg("<span class='notice'>You install the airlock electronics.</span>"); this.name = "near finished windoor assembly"; this.electronics = A; } else { A.loc = this.loc; } } else if (A is Obj_Item_Weapon_Screwdriver) { if (!Lang13.Bool(this.electronics)) { return(null); } GlobalFuncs.playsound(this.loc, "sound/items/Screwdriver.ogg", 100, 1); ((Ent_Static)user).visible_message("" + user + " removes the electronics from the airlock assembly.", "<span class='notice'>You start to uninstall electronics from the airlock assembly...</span>"); if (GlobalFuncs.do_after(user, 40 / A.toolspeed, null, this)) { if (!(this != null) || !Lang13.Bool(this.electronics)) { return(null); } user.WriteMsg("<span class='notice'>You remove the airlock electronics.</span>"); this.name = "wired windoor assembly"; ae = null; ae = this.electronics; this.electronics = null; ae.loc = this.loc; } } else if (A is Obj_Item_Weapon_Pen) { t = GlobalFuncs.stripped_input(user, "Enter the name for the door.", this.name, this.created_name, 26); if (!Lang13.Bool(t)) { return(null); } if (!(Map13.GetDistance(this, Task13.User) <= 1) && this.loc != Task13.User) { return(null); } this.created_name = t; return(null); } else if (A is Obj_Item_Weapon_Crowbar) { if (!Lang13.Bool(this.electronics)) { Task13.User.WriteMsg("<span class='warning'>The assembly is missing electronics!</span>"); return(null); } Interface13.Browse(Task13.User, null, "window=windoor_access"); GlobalFuncs.playsound(this.loc, "sound/items/Crowbar.ogg", 100, 1); ((Ent_Static)user).visible_message("" + user + " pries the windoor into the frame.", "<span class='notice'>You start prying the windoor into the frame...</span>"); if (GlobalFuncs.do_after(user, 40 / A.toolspeed, null, this)) { if (this.loc != null && Lang13.Bool(this.electronics)) { this.density = true; user.WriteMsg("<span class='notice'>You finish the windoor.</span>"); if (this.secure) { windoor = new Obj_Machinery_Door_Window_Brigdoor(this.loc); if (this.facing == "l") { windoor.icon_state = "leftsecureopen"; windoor.base_state = "leftsecure"; } else { windoor.icon_state = "rightsecureopen"; windoor.base_state = "rightsecure"; } windoor.dir = this.dir; windoor.density = false; if (this.electronics.one_access) { windoor.req_one_access = this.electronics.accesses; } else { windoor.req_access = this.electronics.accesses; } windoor.electronics = this.electronics; this.electronics.loc = windoor; if (Lang13.Bool(this.created_name)) { windoor.name = this.created_name; } GlobalFuncs.qdel(this); windoor.close(); } else { windoor2 = new Obj_Machinery_Door_Window(this.loc); if (this.facing == "l") { windoor2.icon_state = "leftopen"; windoor2.base_state = "left"; } else { windoor2.icon_state = "rightopen"; windoor2.base_state = "right"; } windoor2.dir = this.dir; windoor2.density = false; windoor2.req_access = this.electronics.accesses; windoor2.electronics = this.electronics; this.electronics.loc = windoor2; if (Lang13.Bool(this.created_name)) { windoor2.name = this.created_name; } GlobalFuncs.qdel(this); windoor2.close(); } } } } else { base.attackby((object)(A), (object)(user), _params, silent, replace_spent); } break; } this.update_icon(); return(null); }