Ejemplo n.º 1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (currentTarget != null) // if turret is already targeting a player
     {
         return;
     }
     if (collision.gameObject.GetComponent <Player>())
     {
         if (collision.transform == parentPlayer) // if the player owns the turret
         {
             return;
         }
         parentTurret.SetTarget(collision.transform);
         currentTarget = collision.transform;
     }
 }
Ejemplo n.º 2
0
        object CanBeTargeted(BasePlayer player, BaseCombatEntity entity)
        {
            if (permission.UserHasPermission(player.UserIDString, turretsIgnore))
            {
                return(false);
            }

            else if (permission.UserHasPermission(player.UserIDString, turretsNeverIgnore))
            {
                return(null);
            }

            if (entity is NPCAutoTurret && _config.NPCTurretsAffected)
            {
                BuildingPrivlidge priviledge = entity.GetBuildingPrivilege();

                if (priviledge != null && !priviledge.IsAuthed(player) && player.IsBuildingBlocked() && player.IsVisible(new Vector3(entity.transform.position.x, entity.transform.position.y + 0.8f, entity.transform.position.z), new Vector3(player.transform.position.x, player.transform.position.y + 1.5f, player.transform.position.z)))
                {
                    return(null);
                }
                else
                {
                    return(false);
                }
            }

            if ((entity is AutoTurret && !(entity is NPCAutoTurret) && _config.autoturretsAffected))
            {
                AutoTurret turret = entity as AutoTurret;

                BuildingPrivlidge priviledge = turret.GetBuildingPrivilege();

                if (priviledge != null && !priviledge.IsAuthed(player) && player.IsBuildingBlocked() && player.IsVisible(new Vector3(turret.transform.position.x, turret.transform.position.y + 0.8f, turret.transform.position.z), new Vector3(player.transform.position.x, player.transform.position.y + 1.5f, player.transform.position.z)))
                {
                    if (_config.autoturretsShootAuthed && turret.IsAuthed(player))
                    {
                        turret.SetTarget(player);

                        return(null);
                    }
                    else if (!turret.IsAuthed(player))
                    {
                        return(null);
                    }
                }

                return(false);
            }

            if ((entity is FlameTurret && _config.flameTrapsAffected) || (entity is GunTrap && _config.shotgunTrapsAffected) && !player.IsBuildingBlocked() || !player.IsVisible(entity.transform.position, player.transform.position, Mathf.Infinity))
            {
                return(false);
            }

            return(null);
        }
Ejemplo 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);
        }
Ejemplo n.º 4
0
            private void FixedUpdate()
            {
                if (turret != null)
                {
                    turret.SetTarget(null);
                    shooter = mainBoat.mountPoints[4].mountable.GetMounted();

                    if (shooter != null)
                    {
                        turret.aimDir = shooter.eyes.HeadRay().direction;
                        turret?.SendAimDir();
                        turret?.UpdateAiming();
                    }
                    else
                    {
                        turret.aimDir = mainBoat.transform.forward;
                        turret?.SendAimDir();
                        turret?.UpdateAiming();
                    }
                }
            }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public override void Deauthorize(BasePlayer player)
 {
     Turret.authorizedPlayers.RemoveAll(entry => entry.userid == player.userID);
     Turret.SendNetworkUpdate();
     Turret.SetTarget(null);
 }