Exemple #1
0
        // Function from file: machines.dm
        public void makepowernets(dynamic zlevel = null)
        {
            Powernet            PN    = null;
            Obj_Structure_Cable PC    = null;
            Powernet            NewPN = null;


            foreach (dynamic _a in Lang13.Enumerate(this.powernets, typeof(Powernet)))
            {
                PN = _a;

                GlobalFuncs.qdel(PN);
            }
            this.powernets.Cut();

            foreach (dynamic _b in Lang13.Enumerate(GlobalVars.cable_list, typeof(Obj_Structure_Cable)))
            {
                PC = _b;


                if (!(PC.powernet != null))
                {
                    NewPN = new Powernet();
                    NewPN.add_cable(PC);
                    GlobalFuncs.propagate_network(PC, PC.powernet);
                }
            }
            return;
        }
Exemple #2
0
        // Function from file: machines.dm
        public override void fire(  )
        {
            Powernet Powernet = null;
            double   seconds  = 0;
            dynamic  thing    = null;


            foreach (dynamic _a in Lang13.Enumerate(this.powernets, typeof(Powernet)))
            {
                Powernet = _a;

                Powernet.reset();
            }
            seconds = this.wait * 0.1;

            foreach (dynamic _b in Lang13.Enumerate(this.processing))
            {
                thing = _b;


                if (Lang13.Bool(thing) && ((Game_Data)thing).process(seconds) != 26)
                {
                    if (thing.use_power != 0)
                    {
                        ((Obj_Machinery)thing).auto_use_power();
                    }
                    continue;
                }
                this.processing.Remove(thing);
            }
            return;
        }
Exemple #3
0
        // Function from file: cable.dm
        public void denode(  )
        {
            Ent_Static T1        = null;
            ByTable    powerlist = null;
            Powernet   PN        = null;

            T1 = this.loc;

            if (!(T1 != null))
            {
                return;
            }
            powerlist = GlobalFuncs.power_list(T1, this, 0, false);

            if (powerlist.len > 0)
            {
                PN = new Powernet();
                GlobalFuncs.propagate_network(powerlist[1], PN);

                if (PN.is_empty())
                {
                    GlobalFuncs.qdel(PN);
                }
            }
            return;
        }
Exemple #4
0
        // Function from file: work_tools.dm
        public bool layCable(Tile new_turf = null)
        {
            double?fdirn           = null;
            Obj_Structure_Cable LC = null;
            Obj_Structure_Cable NC = null;
            Powernet            PN = null;


            if (this.equip_ready || !(new_turf is Tile) || !this.dismantleFloor(new_turf))
            {
                this.reset(); return(false);
            }
            fdirn = Num13.Rotate(this.chassis.dir, 180);

            foreach (dynamic _a in Lang13.Enumerate(new_turf, typeof(Obj_Structure_Cable)))
            {
                LC = _a;


                if (LC.d1 == fdirn || LC.d2 == fdirn)
                {
                    this.reset(); return(false);
                }
            }

            if (!this.use_cable(1))
            {
                this.reset(); return(false);
            }
            NC = new Obj_Structure_Cable(new_turf);
            NC.cableColor("red");
            NC.d1 = 0;
            NC.d2 = fdirn;
            NC.updateicon();
            PN = null;

            if (this.last_piece != null && this.last_piece.d2 != this.chassis.dir)
            {
                this.last_piece.d1 = Num13.MinInt(((int)(this.last_piece.d2 ?? 0)), this.chassis.dir);
                this.last_piece.d2 = Num13.MaxInt(((int)(this.last_piece.d2 ?? 0)), this.chassis.dir);
                this.last_piece.updateicon();
                PN = this.last_piece.powernet;
            }

            if (!(PN != null))
            {
                PN = new Powernet();
                GlobalVars.powernets.Add(PN);
            }
            NC.powernet = PN;
            PN.cables.Add(NC);
            NC.mergeConnectedNetworks(NC.d2);
            this.last_piece = NC;
            return(true);
        }
Exemple #5
0
        // Function from file: cable.dm
        public void mergeConnectedNetworks(double?direction = null)
        {
            double?fdir               = null;
            Tile   TB                 = null;
            Obj_Structure_Cable C     = null;
            Powernet            newPN = null;

            fdir = (!Lang13.Bool(direction) ? 0 : Num13.Rotate(direction, 180));

            if (!(this.d1 == direction || this.d2 == direction))
            {
                return;
            }
            TB = Map13.GetStep(this, ((int)(direction ?? 0)));

            foreach (dynamic _a in Lang13.Enumerate(TB, typeof(Obj_Structure_Cable)))
            {
                C = _a;


                if (!(C != null))
                {
                    continue;
                }

                if (this == C)
                {
                    continue;
                }

                if (C.d1 == fdir || C.d2 == fdir)
                {
                    if (!(C.powernet != null))
                    {
                        newPN = new Powernet();
                        newPN.add_cable(C);
                    }

                    if (this.powernet != null)
                    {
                        GlobalFuncs.merge_powernets(this.powernet, C.powernet);
                    }
                    else
                    {
                        C.powernet.add_cable(this);
                    }
                }
            }
            return;
        }
Exemple #6
0
        public bool f_power(  )
        {
            Ent_Static T          = null;
            dynamic    C          = null;
            Powernet   PN         = null;
            int        surplus    = 0;
            int        shieldload = 0;


            if (!Lang13.Bool(this.anchored))
            {
                this.power = false;
                return(false);
            }
            T = this.loc;
            C = ((dynamic)T).get_cable_node();

            if (Lang13.Bool(C))
            {
                PN = C.powernet;
            }

            if (!(PN != null))
            {
                this.power = false;
                return(false);
            }
            surplus    = Num13.MaxInt(((int)(PN.avail - PN.load)), 0);
            shieldload = Num13.MinInt(Rand13.Int(50, 200), surplus);

            if (shieldload == 0 && !(this.storedpower != 0))
            {
                this.power = false;
                return(false);
            }
            else
            {
                this.power = true;

                if (PN != null)
                {
                    this.storedpower += shieldload;
                    PN.load          += shieldload;
                }
            }
            return(false);
        }
Exemple #7
0
        // Function from file: machines.dm
        public void setup_template_powernets(ByTable cables = null)
        {
            dynamic  A     = null;
            dynamic  PC    = null;
            Powernet NewPN = null;


            foreach (dynamic _a in Lang13.Enumerate(cables))
            {
                A = _a;

                PC = A;

                if (!Lang13.Bool(PC.powernet))
                {
                    NewPN = new Powernet();
                    NewPN.add_cable(PC);
                    GlobalFuncs.propagate_network(PC, PC.powernet);
                }
            }
            return;
        }
Exemple #8
0
        // Function from file: powersink.dm
        public override int?process(dynamic seconds = null)
        {
            Powernet PN      = null;
            int      drained = 0;
            Obj_Machinery_Power_Terminal T = null;
            Obj_Machinery_Power          A = null;


            if (!Lang13.Bool(this.attached))
            {
                this.set_mode(GlobalVars.DISCONNECTED);
                return(null);
            }
            PN = this.attached.powernet;

            if (PN != null)
            {
                this.SetLuminosity(5);
                drained             = Num13.MinInt(this.drain_rate, ((int)(PN.avail)));
                PN.load            += drained;
                this.power_drained += drained;

                if (drained < this.drain_rate)
                {
                    foreach (dynamic _a in Lang13.Enumerate(PN.nodes, typeof(Obj_Machinery_Power_Terminal)))
                    {
                        T = _a;


                        if (T.master is Obj_Machinery_Power_Apc)
                        {
                            A = T.master;

                            if (Lang13.Bool(((dynamic)A).operating) && Lang13.Bool(((dynamic)A).cell))
                            {
                                ((dynamic)A).cell.charge = Num13.MaxInt(0, Convert.ToInt32(((dynamic)A).cell.charge - 50));
                                this.power_drained      += 50;

                                if (Convert.ToInt32(((dynamic)A).charging) == 2)
                                {
                                    ((dynamic)A).charging = 1;
                                }
                            }
                        }
                    }
                }
            }

            if (this.power_drained > this.max_power * 0.98)
            {
                if (!this.admins_warned)
                {
                    this.admins_warned = true;
                    GlobalFuncs.message_admins("Power sink at (" + this.x + "," + this.y + "," + this.z + " - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=" + this.x + ";Y=" + this.y + ";Z=" + this.z + "'>JMP</a>) is 95% full. Explosion imminent.");
                }
                GlobalFuncs.playsound(this, "sound/effects/screech.ogg", 100, 1, 1);
            }

            if (this.power_drained >= this.max_power)
            {
                GlobalVars.SSobj.processing.Remove(this);
                GlobalFuncs.explosion(this.loc, 4, 8, 16, 32);
                GlobalFuncs.qdel(this);
            }
            return(null);
        }
Exemple #9
0
        // Function from file: cable.dm
        public void cable_join(Obj_Structure_Cable C = null, dynamic user = null)
        {
            Ent_Static          U     = null;
            Ent_Static          T     = null;
            double?             dirn  = null;
            double?             fdirn = null;
            Obj_Structure_Cable LC    = null;
            dynamic             NC    = null;
            Powernet            newPN = null;
            double?             nd1   = null;
            double?             nd2   = null;
            Obj_Structure_Cable LC2   = null;

            U = user.loc;

            if (!(U is Tile))
            {
                return;
            }
            T = C.loc;

            if (!(T is Tile) || Lang13.Bool(((dynamic)T).intact))
            {
                return;
            }

            if (Map13.GetDistance(C, user) > 1)
            {
                user.WriteMsg("<span class='warning'>You can't lay cable at a place that far away!</span>");
                return;
            }

            if (U == T)
            {
                this.place_turf(T, user);
                return;
            }
            dirn = Map13.GetDistance(C, user);

            if (C.d1 == dirn || C.d2 == dirn)
            {
                if (!Lang13.Bool(((dynamic)U).can_have_cabling()))
                {
                    user.WriteMsg("<span class='warning'>You can only lay cables on catwalks and plating!</span>");
                    return;
                }

                if (Lang13.Bool(((dynamic)U).intact))
                {
                    user.WriteMsg("<span class='warning'>You can't lay cable there unless the floor tiles are removed!</span>");
                    return;
                }
                else
                {
                    fdirn = Num13.Rotate(dirn, 180);

                    foreach (dynamic _a in Lang13.Enumerate(U, typeof(Obj_Structure_Cable)))
                    {
                        LC = _a;


                        if (LC.d1 == fdirn || LC.d2 == fdirn)
                        {
                            user.WriteMsg("<span class='warning'>There's already a cable at that position!</span>");
                            return;
                        }
                    }
                    NC    = this.get_new_cable(U);
                    NC.d1 = 0;
                    NC.d2 = fdirn;
                    ((Ent_Static)NC).add_fingerprint();
                    NC.updateicon();
                    newPN = new Powernet();
                    newPN.add_cable(NC);
                    ((Obj_Structure_Cable)NC).mergeConnectedNetworks(NC.d2);
                    ((Obj_Structure_Cable)NC).mergeConnectedNetworksOnTurf();

                    if ((((int)(NC.d2 ?? 0)) & ((int)((NC.d2 ?? 0) - 1))) != 0)
                    {
                        ((Obj_Structure_Cable)NC).mergeDiagonalsNetworks(NC.d2);
                    }
                    this.use(1);

                    if (((Obj_Structure_Cable)NC).shock(user, 50))
                    {
                        if (Rand13.PercentChance(50))
                        {
                            ((Obj)NC).Deconstruct();
                        }
                    }
                    return;
                }
            }
            else if (C.d1 == 0)
            {
                nd1 = C.d2;
                nd2 = dirn;

                if ((nd1 ?? 0) > (nd2 ?? 0))
                {
                    nd1 = dirn;
                    nd2 = C.d2;
                }

                foreach (dynamic _b in Lang13.Enumerate(T, typeof(Obj_Structure_Cable)))
                {
                    LC2 = _b;


                    if (LC2 == C)
                    {
                        continue;
                    }

                    if (LC2.d1 == nd1 && LC2.d2 == nd2 || LC2.d1 == nd2 && LC2.d2 == nd1)
                    {
                        user.WriteMsg("<span class='warning'>There's already a cable at that position!</span>");
                        return;
                    }
                }
                C.cableColor(this.item_color);
                C.d1 = nd1;
                C.d2 = nd2;
                C.update_stored(2, this.item_color);
                C.add_fingerprint();
                C.updateicon();
                C.mergeConnectedNetworks(C.d1);
                C.mergeConnectedNetworks(C.d2);
                C.mergeConnectedNetworksOnTurf();

                if ((((int)(C.d1 ?? 0)) & ((int)((C.d1 ?? 0) - 1))) != 0)
                {
                    C.mergeDiagonalsNetworks(C.d1);
                }

                if ((((int)(C.d2 ?? 0)) & ((int)((C.d2 ?? 0) - 1))) != 0)
                {
                    C.mergeDiagonalsNetworks(C.d2);
                }
                this.use(1);

                if (C.shock(user, 50))
                {
                    if (Rand13.PercentChance(50))
                    {
                        C.Deconstruct();
                        return;
                    }
                }
                C.denode();
                return;
            }
            return;
        }
Exemple #10
0
        // Function from file: cable.dm
        public void place_turf(Ent_Static T = null, dynamic user = null)
        {
            double?dirn            = null;
            Obj_Structure_Cable LC = null;
            dynamic             C  = null;
            Powernet            PN = null;


            if (!(user.loc is Tile))
            {
                return;
            }

            if (!Lang13.Bool(((dynamic)T).can_have_cabling()))
            {
                user.WriteMsg("<span class='warning'>You can only lay cables on catwalks and plating!</span>");
                return;
            }

            if ((this.get_amount() ?? 0) < 1)
            {
                user.WriteMsg("<span class='warning'>There is no cable left!</span>");
                return;
            }

            if (Map13.GetDistance(T, user) > 1)
            {
                user.WriteMsg("<span class='warning'>You can't lay cable at a place that far away!</span>");
                return;
            }
            else
            {
                if (user.loc == T)
                {
                    dirn = Lang13.DoubleNullable(user.dir);
                }
                else
                {
                    dirn = Map13.GetDistance(T, user);
                }

                foreach (dynamic _a in Lang13.Enumerate(T, typeof(Obj_Structure_Cable)))
                {
                    LC = _a;


                    if (LC.d2 == dirn && LC.d1 == 0)
                    {
                        user.WriteMsg("<span class='warning'>There's already a cable at that position!</span>");
                        return;
                    }
                }
                C    = this.get_new_cable(T);
                C.d1 = 0;
                C.d2 = dirn;
                ((Ent_Static)C).add_fingerprint(user);
                C.updateicon();
                PN = new Powernet();
                PN.add_cable(C);
                ((Obj_Structure_Cable)C).mergeConnectedNetworks(C.d2);
                ((Obj_Structure_Cable)C).mergeConnectedNetworksOnTurf();

                if ((((int)(C.d2 ?? 0)) & ((int)((C.d2 ?? 0) - 1))) != 0)
                {
                    ((Obj_Structure_Cable)C).mergeDiagonalsNetworks(C.d2);
                }
                this.use(1);

                if (((Obj_Structure_Cable)C).shock(user, 50))
                {
                    if (Rand13.PercentChance(50))
                    {
                        ((Obj)C).Deconstruct();
                    }
                }
            }
            return;
        }
Exemple #11
0
        // Function from file: ninjaDrainAct.dm
        public override dynamic ninjadrain_act(Obj_Item_Clothing_Suit_Space_SpaceNinja S = null, Ent_Static H = null, Obj_Item_Clothing_Gloves_SpaceNinja G = null)
        {
            dynamic _default = null;

            bool     maxcapacity            = false;
            int      drain                  = 0;
            Powernet PN                     = null;
            int      drained                = 0;
            Obj_Machinery_Power_Terminal T  = null;
            Obj_Machinery_Power          AP = null;


            if (!(S != null) || !(H != null) || !(G != null))
            {
                return("INVALID");
            }
            maxcapacity = false;
            drain       = 0;
            _default    = 0;
            PN          = this.powernet;

            while (G.candrain && !maxcapacity && this != null)
            {
                drain   = Num13.Floor(Rand13.Int(G.mindrain, G.maxdrain) / 2);
                drained = 0;

                if (PN != null && GlobalFuncs.do_after(H, 10, null, this))
                {
                    drained  = Num13.MinInt(drain, ((int)(PN.avail)));
                    PN.load += drained;

                    if (drained < drain)
                    {
                        foreach (dynamic _a in Lang13.Enumerate(PN.nodes, typeof(Obj_Machinery_Power_Terminal)))
                        {
                            T = _a;


                            if (T.master is Obj_Machinery_Power_Apc)
                            {
                                AP = T.master;

                                if (Lang13.Bool(((dynamic)AP).operating) && Lang13.Bool(((dynamic)AP).cell) && Convert.ToDouble(((dynamic)AP).cell.charge) > 0)
                                {
                                    ((dynamic)AP).cell.charge = Num13.MaxInt(0, Convert.ToInt32(((dynamic)AP).cell.charge - 5));
                                    drained += 5;
                                }
                            }
                        }
                    }
                }
                else
                {
                    break;
                }
                S.cell.charge += drained;

                if (Convert.ToDouble(S.cell.charge) > (S.cell.maxcharge ?? 0))
                {
                    _default     += drained - Convert.ToDouble(S.cell.charge - S.cell.maxcharge);
                    S.cell.charge = S.cell.maxcharge;
                    maxcapacity   = true;
                }
                else
                {
                    _default += drained;
                }
                S.spark_system.start();
            }
            return(_default);
        }
Exemple #12
0
        // Function from file: cable.dm
        public void mergeDiagonalsNetworks(double?direction = null)
        {
            Tile T = null;
            Obj_Structure_Cable C      = null;
            Powernet            newPN  = null;
            Obj_Structure_Cable C2     = null;
            Powernet            newPN2 = null;

            T = Map13.GetStep(this, ((int)(direction ?? 0)) & 3);

            foreach (dynamic _a in Lang13.Enumerate(T, typeof(Obj_Structure_Cable)))
            {
                C = _a;


                if (!(C != null))
                {
                    continue;
                }

                if (this == C)
                {
                    continue;
                }

                if (C.d1 == (((int)(direction ?? 0)) ^ 3) || C.d2 == (((int)(direction ?? 0)) ^ 3))
                {
                    if (!(C.powernet != null))
                    {
                        newPN = new Powernet();
                        newPN.add_cable(C);
                    }

                    if (this.powernet != null)
                    {
                        GlobalFuncs.merge_powernets(this.powernet, C.powernet);
                    }
                    else
                    {
                        C.powernet.add_cable(this);
                    }
                }
            }
            T = Map13.GetStep(this, ((int)(direction ?? 0)) & 12);

            foreach (dynamic _b in Lang13.Enumerate(T, typeof(Obj_Structure_Cable)))
            {
                C2 = _b;


                if (!(C2 != null))
                {
                    continue;
                }

                if (this == C2)
                {
                    continue;
                }

                if (C2.d1 == (((int)(direction ?? 0)) ^ 12) || C2.d2 == (((int)(direction ?? 0)) ^ 12))
                {
                    if (!(C2.powernet != null))
                    {
                        newPN2 = new Powernet();
                        newPN2.add_cable(C2);
                    }

                    if (this.powernet != null)
                    {
                        GlobalFuncs.merge_powernets(this.powernet, C2.powernet);
                    }
                    else
                    {
                        C2.powernet.add_cable(this);
                    }
                }
            }
            return;
        }
Exemple #13
0
        // 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;
        }
Exemple #14
0
        // 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;
        }