// Function from file: field_generator.dm public bool calc_power( ) { int power_draw = 0; Obj_Machinery_Field_Containment F = null; if (this.Varpower) { return(true); } this.update_icon(); if ((this.power ?? 0) > 250) { this.power = 250; } power_draw = 2; foreach (dynamic _a in Lang13.Enumerate(this.fields, typeof(Obj_Machinery_Field_Containment))) { F = _a; if (F == null) { continue; } power_draw++; } if (this.draw_power(Num13.Round(power_draw / 2, 1))) { return(true); } else { this.visible_message("<span class='danger'>The " + this.name + " shuts down!</span>", "<span class='italics'>You hear something shutting down.</span>"); this.turn_off(); this.investigate_log("ran out of power and <font color='red'>deactivated</font>", "singulo"); this.power = 0; return(false); } }
// Function from file: field_generator.dm public void cleanup( ) { Obj_Machinery_Field_Containment F = null; Obj_Machinery_Field_Generator FG = null; bool temp = false; Obj_Singularity O = null; this.clean_up = true; foreach (dynamic _a in Lang13.Enumerate(this.fields, typeof(Obj_Machinery_Field_Containment))) { F = _a; if (F == null) { continue; } GlobalFuncs.qdel(F); } this.fields = new ByTable(); foreach (dynamic _b in Lang13.Enumerate(this.connected_gens, typeof(Obj_Machinery_Field_Generator))) { FG = _b; if (FG == null) { continue; } FG.connected_gens.Remove(this); if (!FG.clean_up) { FG.cleanup(); } this.connected_gens.Remove(FG); } this.connected_gens = new ByTable(); this.clean_up = false; this.update_icon(); Task13.Schedule(1, (Task13.Closure)(() => { temp = true; foreach (dynamic _c in Lang13.Enumerate(typeof(Game13), typeof(Obj_Singularity))) { O = _c; if (O.last_warning != 0 && temp) { if (Game13.time - O.last_warning > 50) { temp = false; GlobalFuncs.message_admins("A singulo exists and a containment field has failed."); this.investigate_log("has <font color='red'>failed</font> whilst a singulo exists.", "singulo"); } } O.last_warning = Game13.time; } return; })); return; }
// Function from file: field_generator.dm public bool setup_field(int NSEW = 0) { Ent_Static T = null; dynamic G = null; int? steps = null; int? dist = null; Ent_Static A = null; int? dist2 = null; int field_dir = 0; Obj_Machinery_Field_Containment CF = null; Mob_Living L = null; bool listcheck = false; Obj_Machinery_Field_Generator FG = null; Obj_Machinery_Field_Generator FG2 = null; T = this.loc; steps = 0; if (!(NSEW != 0)) { return(false); } dist = null; dist = 0; while ((dist ?? 0) <= 9) { T = Map13.GetStep(T, NSEW); if (T.density) { return(false); } foreach (dynamic _a in Lang13.Enumerate(T.contents, typeof(Ent_Static))) { A = _a; if (A is Mob) { continue; } if (!(A is Obj_Machinery_Field_Generator)) { if ((A is Obj_Machinery_Door || A is Obj_Machinery_TheSingularitygen) && A.density) { return(false); } } } steps += 1; G = Lang13.FindIn(typeof(Obj_Machinery_Field_Generator), T); if (!(G == null)) { steps -= 1; if (!Lang13.Bool(G.active)) { return(false); } break; } dist += 1; } if (G == null) { return(false); } T = this.loc; dist2 = null; dist2 = 0; while ((dist2 ?? 0) < (steps ?? 0)) { field_dir = Map13.GetDistance(T, Map13.GetStep(G.loc, NSEW)); T = Map13.GetStep(T, NSEW); if (!Lang13.Bool(Lang13.FindIn(typeof(Obj_Machinery_Field_Containment), T))) { CF = new Obj_Machinery_Field_Containment(); CF.set_master(this, G); this.fields.Add(CF); G.fields += CF; CF.loc = T; CF.dir = field_dir; foreach (dynamic _b in Lang13.Enumerate(CF.loc, typeof(Mob_Living))) { L = _b; CF.Crossed(L); } } dist2 += 1; } listcheck = false; foreach (dynamic _c in Lang13.Enumerate(this.connected_gens, typeof(Obj_Machinery_Field_Generator))) { FG = _c; if (FG == null) { continue; } if (FG == G) { listcheck = true; break; } } if (!listcheck) { this.connected_gens.Add(G); } listcheck = false; foreach (dynamic _d in Lang13.Enumerate(G.connected_gens, typeof(Obj_Machinery_Field_Generator))) { FG2 = _d; if (FG2 == null) { continue; } if (FG2 == this) { listcheck = true; break; } } if (!listcheck) { G.connected_gens.Add(this); } return(false); }