Ejemplo n.º 1
0
        /// <summary>
        /// Returns true if the player can access the given terminal block. Blocks without ownership
        /// permissions require the player to have at least friendly relations with a big owner's faction.
        /// </summary>
        public static TerminalPermissionStates GetAccessPermissions(this IMyTerminalBlock block, long plyID = -1)
        {
            IMyCubeGrid grid = block.CubeGrid;
            TerminalPermissionStates accessState;

            if (plyID == -1)
            {
                plyID = MyAPIGateway.Session.LocalHumanPlayer.IdentityId;
            }

            if (block.GetIsBlockOwnable())
            {
                if (block.HasPlayerAccess(plyID))
                {
                    accessState = TerminalPermissionStates.Granted | TerminalPermissionStates.BlockFriendly;
                }
                else
                {
                    accessState = TerminalPermissionStates.Denied | TerminalPermissionStates.BlockUnfriendly;
                }

                return(accessState);
            }
            else
            {
                return(grid.GetAccessPermissions(plyID));
            }
        }