• Hello
Search Results for

    Show / Hide Table of Contents

    Class AntiCheatMonitor

    Central anti-cheat coordinator: aggregates threats from all children and dispatches to all children. Implemented as a persistent singleton.

    Inheritance
    System.Object
    AntiCheatMonitor
    Implements
    IWatcher<IDetectorStatus>
    Namespace: GUPS.AntiCheat
    Assembly: cs.temp.dll.dll
    Syntax
    public class AntiCheatMonitor : Singleton<AntiCheatMonitor>
    Remarks

    On Awake the monitor discovers detectors and punishers under its , subscribes to each supported detector and sorts the punishers by ascending . Incoming detection events raise the internal threat level (scaled by SensitiveLevel and the reported false-positive chance), which slowly decays during FixedUpdate.

    Examples

    Place a single AntiCheatMonitor in your bootstrap scene; it persists across scene loads and exposes detectors / punishers via GetDetector<TDetector>() / :

    using GUPS.AntiCheat;
    using GUPS.AntiCheat.Detector;
    using GUPS.AntiCheat.Punisher;
    using UnityEngine;
    
    var monitor = AntiCheatMonitor.Instance;
    
    // React to primitive-tampering events via the detector's UnityEvent.
    var primitiveDetector = monitor.GetDetector<PrimitiveCheatingDetector>();
    primitiveDetector?.OnCheatingDetectionEvent.AddListener(
        status => Debug.LogWarning($"Cheat detected (rating={status.ThreatRating})."));
    
    // Attach a punisher as a child of the monitor's GameObject so it is auto-registered.
    var punisherHost = new GameObject("ExitGamePunisher");
    punisherHost.transform.SetParent(monitor.transform);
    punisherHost.AddComponent<ExitGamePunisher>();

    See GlobalSettings for project-wide configuration.

    Properties

    IsPersistent

    Declaration
    public override bool IsPersistent { get; }
    Property Value
    Type Description
    System.Boolean

    SensitiveLevel

    Gets the reaction sensitivity used to scale incoming threat ratings, from NOT_SENSITIVE (0) to VERY_SENSITIVE (4).

    Declaration
    public ESensitiveLevel SensitiveLevel { get; }
    Property Value
    Type Description
    ESensitiveLevel

    ThreatLevel

    Gets the current accumulated threat level. Decays over time in FixedUpdate.

    Declaration
    public float ThreatLevel { get; }
    Property Value
    Type Description
    System.Single

    Methods

    Awake()

    Discovers and registers all supported detectors and punishers under the monitor's children, then sorts punishers by ascending threat rating.

    Declaration
    protected override void Awake()

    Dispose()

    Declaration
    public void Dispose()

    FixedUpdate()

    Decays the threat level by a factor that grows when SensitiveLevel is low.

    Declaration
    protected virtual void FixedUpdate()

    GetDetector<TDetector>()

    Returns the first registered detector assignable to TDetector, or default if none is found.

    Declaration
    public TDetector GetDetector<TDetector>()
        where TDetector : IDetector
    Returns
    Type Description
    TDetector

    The matching detector, or default.

    Type Parameters
    Name Description
    TDetector

    Detector type to look up.

    GetPunisher(UInt32)

    Returns all active punishers whose is at most _ThreatLevel and that are still allowed to fire.

    Declaration
    public List<IPunisher> GetPunisher(UInt32 _ThreatLevel)
    Parameters
    Type Name Description
    UInt32 _ThreatLevel

    The current threat level.

    Returns
    Type Description
    List<IPunisher>

    Matching punishers in ascending threat-rating order.

    OnCompleted()

    Notification from a detector that it completed. No-op.

    Declaration
    public void OnCompleted()

    OnError(Exception)

    Notification from a detector that an error occurred. No-op.

    Declaration
    public void OnError(Exception _Error)
    Parameters
    Type Name Description
    Exception _Error

    The error that occurred.

    OnNext(IDetectorStatus)

    Receives a threat status from a subscribed detector, updates ThreatLevel and triggers every eligible punisher.

    Declaration
    public void OnNext(IDetectorStatus value)
    Parameters
    Type Name Description
    IDetectorStatus value

    The reported detector status.

    Implements

    IWatcher<>
    In This Article
    Back to top GuardingPearSoftware documentation