Exemplo n.º 1
0
 private static void AddPlayer(AutoTurret turret, PlayerNameID playerNameId)
 {
     RemovePlayer(turret, playerNameId.userid);
     turret.authorizedPlayers.Add(playerNameId);
     turret.target = null;
     turret.SendNetworkUpdate();
 }
Exemplo n.º 2
0
 private static void RemovePlayer(AutoTurret turret, ulong userId)
 {
     for (int i = turret.authorizedPlayers.Count - 1; i >= 0; i--)
     {
         if (turret.authorizedPlayers[i].userid != userId)
         {
             continue;
         }
         turret.authorizedPlayers.RemoveAt(i);
         turret.SendNetworkUpdate();
         break;
     }
 }
Exemplo n.º 3
0
        private bool AddToWhiteList(AutoTurret at, BasePlayer player)
        {
            if (at.IsAuthed(player))
            {
                return(false);
            }

            var protobufPlayer = new ProtoBuf.PlayerNameID();

            protobufPlayer.userid   = player.userID;
            protobufPlayer.username = player.name;

            at.authorizedPlayers.Add(protobufPlayer);
            at.SendNetworkUpdate();
            at.SetTarget(null);

            return(true);
        }
Exemplo n.º 4
0
        private bool RemoveFromWhiteList(AutoTurret at, BasePlayer player)
        {
            if (!at.IsAuthed(player))
            {
                return(false);
            }

            int i = 0;

            foreach (var authedPlayer in at.authorizedPlayers)
            {
                if (authedPlayer.userid == player.userID)
                {
                    at.authorizedPlayers.RemoveAt(i);
                    at.SendNetworkUpdate();
                    at.SetTarget(null);
                    return(true);
                }
                i++;
            }
            return(false);
        }
        void AddTurret(MiniCopter copter)
        {
            AutoTurret aturret = GameManager.server.CreateEntity(autoturretPrefab, copter.transform.position) as AutoTurret;

            DestroyMeshCollider(aturret);
            DestroyGroundComp(aturret);
            aturret.Spawn();
            aturret.pickup.enabled = false;
            aturret.sightRange     = config.turretRange;
            aturret.SetParent(copter);
            aturret.transform.localPosition = new Vector3(0, 0, 2.47f);
            aturret.transform.localRotation = Quaternion.Euler(0, 0, 0);
            ProtoBuf.PlayerNameID pnid   = new ProtoBuf.PlayerNameID();
            BasePlayer            player = BasePlayer.FindByID(copter.OwnerID);

            if (player != null)
            {
                pnid.userid   = player.userID;
                pnid.username = player?.displayName;
                aturret.authorizedPlayers.Add(pnid);
            }
            aturret.SendNetworkUpdate();
            AddSwitch(aturret);
        }
Exemplo n.º 6
0
 private static void Auth(AutoTurret turret, PlayerNameID playerNameId)
 {
     turret.authorizedPlayers.Add(playerNameId);
     turret.SendNetworkUpdate();
 }
Exemplo n.º 7
0
 public override void Authorize(BasePlayer player)
 {
     Turret.authorizedPlayers.Add(CreateAuthListEntry(player));
     Turret.SendNetworkUpdate();
 }