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); }
private object OnTurretAuthorize(AutoTurret turret, BasePlayer player) { if (player.IPlayer.HasPermission(PermissionIgnore)) { return(null); } var limit = Configuration.Limit.Find(turret.ShortPrefabName); if (limit == null || turret.authorizedPlayers.Count < limit.MaxAuthorized) { return(null); } if (limit.NoDecaying && IsDecaying(turret.GetBuildingPrivilege())) { return(null); } if (limit.Deauthorize) { if (turret.authorizedPlayers.Count > 0) { if (limit.DeauthorizeAll) { turret.authorizedPlayers.Clear(); } else { turret.authorizedPlayers.RemoveAt(0); } } NotifyDeauthorize(limit, turret, player); } else { NotifyAuthorize(limit, turret, player); } if (limit.Enforce) { return(true); } return(null); }
public void ToggleTurret(AutoTurret turret, BasePlayer player = null) { if (turret == null) { return; } if (player != null && (!turret.IsAuthed(player) || turret.GetBuildingPrivilege()?.IsAuthed(player) == false)) { player.ChatMessage(_instance.Lang("NoPermThisTurret", player.UserIDString)); return; } if (turret.IsOnline()) { PowerTurretOff(turret); } else { PowerTurretOn(turret); } }