Beispiel #1
0
        private void Attach(IMyCubeGrid grid, bool force)
        {
            if (!force && grid == curAttTo)
            {
                return;
            }

            Detach();

            myGrid = myBlock.CubeGrid;
            myGrid.OnMarkForClose += Detach;
            grid.OnMarkForClose   += Detach;

            Logger.DebugLog("attaching " + myGrid.DisplayName + " to " + grid.DisplayName, Logger.severity.DEBUG);
            AttachedGrid.AddRemoveConnection(AttachmentKind, myGrid, grid, true);
            curAttTo = grid;
        }
Beispiel #2
0
        internal static void AddRemoveConnection(AttachmentKind kind, IMyCubeGrid grid1, IMyCubeGrid grid2, bool add)
        {
            if (grid1 == grid2 || Globals.WorldClosed)
            {
                return;
            }

            AttachedGrid
                attached1 = GetFor(grid1),
                attached2 = GetFor(grid2);

            if (attached1 == null || attached2 == null)
            {
                return;
            }

            attached1.AddRemoveConnection(kind, attached2, add);
            attached2.AddRemoveConnection(kind, attached1, add);
        }
Beispiel #3
0
        protected void Detach()
        {
            if (curAttTo == null)
            {
                return;
            }

            if (Globals.WorldClosed)
            {
                return;
            }

            myGrid.OnMarkForClose   -= Detach;
            curAttTo.OnMarkForClose -= Detach;
            if (curAttToBlock != null)
            {
                curAttToBlock.OnMarkForClose -= Detach;
                curAttToBlock = null;
            }

            Logger.DebugLog("detaching " + myGrid.DisplayName + " from " + curAttTo.DisplayName, Logger.severity.DEBUG);
            AttachedGrid.AddRemoveConnection(AttachmentKind, myGrid, curAttTo, false);
            curAttTo = null;
        }