// System using System; using System.Reflection; // Unity using UnityEngine; // GUPS - AntiCheat - Core using GUPS.AntiCheat.Core.Punisher; namespace GUPS.AntiCheat.Punisher { /// /// The reduce fps punisher reduces the max frame rate to a custom low value. Can be very annoying for cheaters. /// [Serializable] [Obfuscation(Exclude = true)] public class ReduceFpsPunisher : MonoBehaviour, IPunisher { // Name #region Name /// /// The name of the punisher. /// public String Name => "Reduce FPS Punisher"; #endregion // Platform #region Platform /// /// Is supported on all platforms. /// public bool IsSupported => true; /// /// Gets or sets whether the punisher is active and can administer punitive actions (Default: true). /// [SerializeField] [Header("Punisher - Settings")] [Tooltip("Gets or sets whether the punisher is active and can administer punitive actions (Default: true).")] private bool isActive = true; /// /// Gets or sets whether the punisher is active and can administer punitive actions (Default: true). /// public bool IsActive { get => this.isActive; set => this.isActive = value; } #endregion // Threat Rating #region Threat Rating /// /// Is a funny punishment, and can be very annoying for cheaters (Default: 550). /// [SerializeField] [Tooltip("Is a funny punishment, and can be very annoying for cheaters (Default: 550).")] private uint threatRating = 550; /// /// Is a funny punishment, and can be very annoying for cheaters (Default: 550). /// public uint ThreatRating => this.threatRating; #endregion // Punishment #region Punishment /// /// Reduce the max frame rate to a low value. /// [SerializeField] [Tooltip("The target frame rate. Reduce it to a low value to annoy players once caught cheating!")] private int punishFrameRate = 30; /// /// Returns if the punisher should only administer punitive actions once or any time the threat level exceeds the threat rating. /// public bool PunishOnce => true; /// /// Returns if the punisher has administered punitive actions. /// public bool HasPunished { get; private set; } = false; /// /// Reduce the max frame rate as punishment. /// public void Punish() { // Has punished. this.HasPunished = true; // Reduce the max frame rate. QualitySettings.vSyncCount = 0; Application.targetFrameRate = this.punishFrameRate; } #endregion } }