Exemplo n.º 1
0
        static bool LookupSurface(string addr, IMyGridTerminalSystem gts, out IMyTerminalBlock block, out int surfid)
        {   //finds a block and a surface that correspond to the given address string
            long blockid;

            block  = null;
            surfid = 0;
            int sepidx = addr.LastIndexOf('/');

            if (sepidx < 0)
            {
                sepidx = addr.Length;
            }
            if (addr[0] != '@')
            {
                block = gts.GetBlockWithName(addr.Substring(0, sepidx));
            }
            else if (long.TryParse(addr.Substring(0, sepidx), out blockid))
            {
                block = gts.GetBlockWithId(blockid);
            }
            var p = block as IMyTextSurfaceProvider;

            if (p == null)
            {
                return(false);
            }
            return((sepidx == addr.Length) || int.TryParse(addr.Substring(sepidx + 1), out surfid));
        }
            //


            /// <summary>
            /// Checks if the specified block has been closed/deleted from the construct
            /// </summary>
            /// <param name="block">The block to check</param>
            /// <returns></returns>
            public bool IsClosed(IMyTerminalBlock block)
            {
                if (block == null || block.WorldMatrix == MatrixD.Identity)
                {
                    return(true);
                }
                return(!(GridTerminalSystem.GetBlockWithId(block.EntityId) == block));
            }
Exemplo n.º 3
0
            public void PerformSelfDiagnostic()
            {
                IMyGridTerminalSystem GridTerminalSystem = MyInstance.GridTerminalSystem;

                if (CTRL != null && GridTerminalSystem.GetBlockWithId(this.CTRL.EntityId) == null)
                {
                    CTRL = null;
                }
                if (XROT != null && GridTerminalSystem.GetBlockWithId(this.XROT.EntityId) == null)
                {
                    XROT = null;
                }
                if (YROT != null && GridTerminalSystem.GetBlockWithId(this.YROT.EntityId) == null)
                {
                    YROT = null;
                }
                if (YROTA != null && GridTerminalSystem.GetBlockWithId(this.YROTA.EntityId) == null)
                {
                    YROTA = null;
                }
                if (RLDCon != null && GridTerminalSystem.GetBlockWithId(this.RLDCon.EntityId) == null)
                {
                    RLDCon = null;
                }
                if (BSDCon != null && GridTerminalSystem.GetBlockWithId(this.BSDCon.EntityId) == null)
                {
                    BSDCon = null;
                }
                if (Camera != null && GridTerminalSystem.GetBlockWithId(this.Camera.EntityId) == null)
                {
                    Camera = null;
                }
            }
Exemplo n.º 4
0
 public T Get(IMyGridTerminalSystem g) {
     if (block == null || g.GetBlockWithId(block.EntityId) == null) { block = lookup(g); }
     return block;
 }