// Function from file: powernet.dm public void add_machine(Obj_Machinery_Power M = null) { if (Lang13.Bool(M.powernet)) { if (M.powernet == this) { return; } else { M.disconnect_from_network(); } } M.powernet = this; this.nodes[M] = M; return; }
// Function from file: cable.dm public void mergeConnectedNetworksOnTurf( ) { ByTable to_connect = null; Powernet newPN = null; dynamic AM = null; dynamic C = null; dynamic N = null; dynamic M = null; Obj_Machinery_Power PM = null; to_connect = new ByTable(); if (!(this.powernet != null)) { newPN = new Powernet(); newPN.add_cable(this); } foreach (dynamic _a in Lang13.Enumerate(this.loc)) { AM = _a; if (AM is Obj_Structure_Cable) { C = AM; if (C.d1 == this.d1 || C.d2 == this.d1 || C.d1 == this.d2 || C.d2 == this.d2) { if (C.powernet == this.powernet) { continue; } if (Lang13.Bool(C.powernet)) { GlobalFuncs.merge_powernets(this.powernet, C.powernet); } else { this.powernet.add_cable(C); } } } else if (AM is Obj_Machinery_Power_Apc) { N = AM; if (!Lang13.Bool(N.terminal)) { continue; } if (N.terminal.powernet == this.powernet) { continue; } to_connect.Add(N.terminal); } else if (AM is Obj_Machinery_Power) { M = AM; if (M.powernet == this.powernet) { continue; } to_connect.Add(M); } } foreach (dynamic _b in Lang13.Enumerate(to_connect, typeof(Obj_Machinery_Power))) { PM = _b; if (!PM.connect_to_network()) { PM.disconnect_from_network(); } } return; }
// Function from file: cable.dm public void cut_cable_from_powernet( ) { Ent_Static T1 = null; ByTable P_list = null; Obj_Machinery_Power P = null; dynamic O = null; Powernet newPN = null; Obj_Machinery_Power P2 = null; T1 = this.loc; if (!(T1 != null)) { return; } if (Lang13.Bool(this.d1)) { T1 = Map13.GetStep(T1, ((int)(this.d1 ?? 0))); P_list = GlobalFuncs.power_list(T1, this, Num13.Rotate(this.d1, 180), false, true); } P_list.Add(GlobalFuncs.power_list(this.loc, this, this.d1, false, true)); if (P_list.len == 0) { this.powernet.remove_cable(this); foreach (dynamic _a in Lang13.Enumerate(T1, typeof(Obj_Machinery_Power))) { P = _a; if (!P.connect_to_network()) { P.disconnect_from_network(); } } return; } O = P_list[1]; this.loc = null; this.powernet.remove_cable(this); Task13.Schedule(0, (Task13.Closure)(() => { if (Lang13.Bool(O) && !Lang13.Bool(GlobalFuncs.qdeleted(O))) { newPN = new Powernet(); GlobalFuncs.propagate_network(O, newPN); } return; })); if (this.d1 == 0) { foreach (dynamic _b in Lang13.Enumerate(T1, typeof(Obj_Machinery_Power))) { P2 = _b; if (!P2.connect_to_network()) { P2.disconnect_from_network(); } } } return; }