Exemple #1
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;
        }
Exemple #4
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;
        }