Exemplo n.º 1
0
        /// <summary>
        /// Determines whether the projected grid still fits within block limits set by server after a new block is added
        /// </summary>
        private bool IsWithinWorldLimits(MyProjectorBase projector, string name)
        {
            if (!MySession.Static.EnableBlockLimits)
            {
                return(true);
            }

            bool withinLimits = true;
            var  identity     = MySession.Static.Players.TryGetIdentity(BuiltBy);

            if (MySession.Static.MaxBlocksPerPlayer > 0)
            {
                withinLimits &= BuiltBy == 0 || IDModule.GetUserRelationToOwner(BuiltBy) != MyRelationsBetweenPlayerAndBlock.Enemies;                     // Don't allow stolen enemy welders to build
                withinLimits &= projector.BuiltBy == 0 || IDModule.GetUserRelationToOwner(projector.BuiltBy) != MyRelationsBetweenPlayerAndBlock.Enemies; // Don't allow welders to build from enemy projectors
                withinLimits &= identity == null || identity.BlocksBuilt < MySession.Static.MaxBlocksPerPlayer + identity.BlockLimitModifier;
            }
            withinLimits &= MySession.Static.MaxGridSize == 0 || projector.CubeGrid.BlocksCount < MySession.Static.MaxGridSize;
            short typeLimit = MySession.Static.GetBlockTypeLimit(name);
            int   typeBuilt;

            if (identity != null && typeLimit > 0)
            {
                withinLimits &= (identity.BlockTypeBuilt.TryGetValue(name, out typeBuilt) ? typeBuilt : 0) < typeLimit;
            }
            return(withinLimits);
        }
Exemplo n.º 2
0
        public bool CanJumpAndHasAccess(long userId)
        {
            if (!CanJump)
            {
                return(false);
            }

            var relationship = IDModule.GetUserRelationToOwner(userId);

            return(relationship.IsFriendly());
        }
Exemplo n.º 3
0
        public MyRelationsBetweenPlayerAndBlock GetUserRelationToOwner(long playerId)
        {
            if (!MyFakes.SHOW_FACTIONS_GUI)
            {
                return(MyRelationsBetweenPlayerAndBlock.FactionShare);
            }

            if (IDModule == null)
            {
                return(MyRelationsBetweenPlayerAndBlock.FactionShare);
            }

            return(IDModule.GetUserRelationToOwner(playerId));
        }
Exemplo n.º 4
0
        public MyRelationsBetweenPlayerAndBlock GetUserRelationToOwner(long identityId)
        {
            if (!MyFakes.SHOW_FACTIONS_GUI)
            {
                return(MyRelationsBetweenPlayerAndBlock.NoOwnership);
            }

            if (IDModule == null)
            {
                return(MyRelationsBetweenPlayerAndBlock.NoOwnership);
            }

            return(IDModule.GetUserRelationToOwner(identityId));
        }
Exemplo n.º 5
0
        public MyRelationsBetweenPlayerAndBlock GetPlayerRelationToOwner()
        {
            if (!MyFakes.SHOW_FACTIONS_GUI)
            {
                return(MyRelationsBetweenPlayerAndBlock.NoOwnership);
            }

            if (IDModule == null)
            {
                return(MyRelationsBetweenPlayerAndBlock.NoOwnership);
            }

            System.Diagnostics.Debug.Assert(MySession.LocalHumanPlayer != null);
            if (MySession.LocalHumanPlayer != null)
            {
                return(IDModule.GetUserRelationToOwner(MySession.LocalHumanPlayer.Identity.IdentityId));
            }

            return(MyRelationsBetweenPlayerAndBlock.Neutral);
        }