Ejemplo n.º 1
0
        // Function from file: turf.dm
        public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null)
        {
            dynamic             coil = null;
            Obj_Structure_Cable LC   = null;


            if (this.can_lay_cable() != 0 && A is Obj_Item_Stack_CableCoil)
            {
                coil = A;

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


                    if (LC.d1 == 0 || LC.d2 == 0)
                    {
                        LC.attackby(A, user);
                        return(null);
                    }
                }
                ((Obj_Item_Stack_CableCoil)coil).place_turf(this, user);
                return(1);
            }
            return(0);
        }
Ejemplo n.º 2
0
        // Function from file: power.dm
        public ByTable get_marked_connections(  )
        {
            ByTable _default = null;

            double?             cdir = null;
            Tile                T    = null;
            dynamic             card = null;
            Obj_Structure_Cable C    = null;

            _default = new ByTable();

            foreach (dynamic _b in Lang13.Enumerate(GlobalVars.cardinal))
            {
                card = _b;

                T    = Map13.GetStep(this.loc, Convert.ToInt32(card));
                cdir = Map13.GetDistance(T, this.loc);

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


                    if (C.d1 == cdir || C.d2 == cdir)
                    {
                        _default.Add(C);
                    }
                }
            }
            return(_default);
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        // Function from file: power.dm
        public ByTable get_indirect_connections(  )
        {
            ByTable _default = null;

            Obj_Structure_Cable C = null;

            _default = new ByTable();

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


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

                if (C.d1 == 0)
                {
                    _default.Add(C);
                }
            }
            return(_default);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
0
        public dynamic _internal_ChangeTurf(dynamic path = null)
        {
            Appearance          s_appearance = null;
            bool                nocopy       = false;
            dynamic             W            = null;
            Obj_Structure_Cable C            = null;


            if (!Lang13.Bool(path))
            {
                return(null);
            }

            if (path == this.type)
            {
                return(this);
            }
            GlobalVars.SSair.remove_from_active(this);
            s_appearance = this.appearance;
            nocopy       = this.density || this.smooth != 0;
            W            = Lang13.Call(path, this);

            if (W is Tile_Simulated)
            {
                ((Tile_Simulated)W).Assimilate_Air();
                ((Tile)W).RemoveLattice();
            }
            ((Tile)W).levelupdate();
            ((Tile)W).CalculateAdjacentTurfs();

            if ((W.smooth & 4) != 0)
            {
                if (!((Tile)W).apply_fixed_underlay())
                {
                    W.underlays += (!nocopy ? ((dynamic)(s_appearance)) : ((dynamic)(new Image("icons/turf/floors.dmi", "plating"))));
                }
            }

            if (!this.can_have_cabling())
            {
                foreach (dynamic _a in Lang13.Enumerate(this.contents, typeof(Obj_Structure_Cable)))
                {
                    C = _a;

                    C.Deconstruct();
                }
            }
            return(W);
        }
        // Function from file: lattice.dm
        public override bool Move(dynamic NewLoc = null, int?Dir = null, int step_x = 0, int step_y = 0)
        {
            Ent_Static          T = null;
            Obj_Structure_Cable C = null;

            T = this.loc;

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

                C.Deconstruct();
            }
            base.Move((object)(NewLoc), Dir, step_x, step_y);
            return(false);
        }
        // Function from file: lattice.dm
        public override void Deconstruct(  )
        {
            Ent_Static          T = null;
            Obj_Structure_Cable C = null;

            T = this.loc;

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

                C.Deconstruct();
            }
            base.Deconstruct();
            return;
        }
Ejemplo n.º 10
0
        // Function from file: power.dm
        public Obj_Structure_Cable get_cable_node(  )
        {
            Obj_Structure_Cable C = null;


            if (!this.can_have_cabling())
            {
                return(null);
            }

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


                if (C.d1 == 0)
                {
                    return(C);
                }
            }
            return(null);
        }
Ejemplo n.º 11
0
        // Function from file: powernet.dm
        public override dynamic Destroy(  )
        {
            Obj_Structure_Cable C = null;
            Obj_Machinery_Power M = null;


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

                this.cables.Remove(C);
                C.powernet = null;
            }

            foreach (dynamic _b in Lang13.Enumerate(this.nodes, typeof(Obj_Machinery_Power)))
            {
                M = _b;

                this.nodes.Remove(M);
                M.powernet = null;
            }
            GlobalVars.SSmachine.powernets.Remove(this);
            return(base.Destroy());
        }
Ejemplo n.º 12
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;
        }
Ejemplo n.º 13
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;
        }
Ejemplo n.º 14
0
 // Function from file: work_tools.dm
 public void reset(  )
 {
     this.last_piece = null;
     return;
 }
Ejemplo n.º 15
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;
        }