Esempio n. 1
0
        private bool CupboardPrivlidge(BasePlayer player, Vector3 position, BaseEntity entity)
        {
            var hits = Physics.OverlapSphere(position, 25f, Rust.Layers.Server.Deployed);
            List <BuildingPrivlidge> buildingPrivilege = new List <BuildingPrivlidge>();

            foreach (var collider in hits)
            {
                var cBoard = collider.GetComponentInParent <BuildingPrivlidge>();
                if (cBoard == null || cBoard == entity)
                {
                    continue;
                }
                buildingPrivilege.Add(cBoard);
            }

            if (buildingPrivilege.Count == 0)
            {
                return(true);
            }


            BuildingPrivlidge cupboard = null;

            for (int i = 0; i < buildingPrivilege.Count; i++)
            {
                BuildingPrivlidge item = buildingPrivilege[i];
                if (item.Dominates(cupboard))
                {
                    cupboard = item;
                }
            }

            List <ulong> ids = (from id in cupboard.authorizedPlayers select id.userid).ToList();


            return(ids.Any(authUserID => authUserID == player.userID));
        }