Class AMonitor<TWatchedSubject>
Abstract base class for monitors in a Unity environment.
Inheritance
Implements
Namespace: GUPS.AntiCheat.Monitor
Assembly: cs.temp.dll.dll
Syntax
public abstract class AMonitor<TWatchedSubject> : MonoBehaviour where TWatchedSubject : class, IWatchedSubject
Type Parameters
| Name | Description |
|---|---|
| TWatchedSubject |
Remarks
Provides the lifecycle (start, pause, resume, stop), a manual ForceRead() and
ForceReadAsync(), and the observer pattern from
Fields
ForceReadTimeoutSeconds
Longest time ForceRead() blocks while
Declaration
protected const double ForceReadTimeoutSeconds = 10
Field Value
| Type | Description |
|---|---|
| System.Double |
Properties
IsActive
Gets a value indicating whether the monitor is active and should be running.
Declaration
public bool IsActive { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsPaused
Gets a value indicating whether the monitor is currently paused.
Declaration
public bool IsPaused { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsStarted
Gets a value indicating whether the monitor has been started and is currently running.
Declaration
public bool IsStarted { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Name
Gets the display name of the monitor.
Declaration
public abstract String Name { get; }
Property Value
| Type | Description |
|---|---|
| String |
Methods
CompletedRead(IWatchedSubject)
Returns a request whose finding is already stored.
Declaration
protected static SubjectRequest CompletedRead(IWatchedSubject _Subject)
Parameters
| Type | Name | Description |
|---|---|---|
| IWatchedSubject | _Subject | The finding. |
Returns
| Type | Description |
|---|---|
| SubjectRequest | A request with |
Dispose()
Notifies all subscribed observers that the monitor has completed and clears the observer list.
Declaration
public void Dispose()
ForceRead()
Runs this monitor's check and returns the finding. Does not notify observers.
Declaration
public virtual IWatchedSubject ForceRead()
Returns
| Type | Description |
|---|---|
| IWatchedSubject | The finding, or |
Remarks
An immediate check overrides this and returns the subject. This base calls ForceReadAsync() and,
when that request is not done yet, blocks until
ForceReadAsync()
Starts this monitor's check and returns a request that is filled when it finishes. Does not notify observers.
Declaration
public virtual SubjectRequest ForceReadAsync()
Returns
| Type | Description |
|---|---|
| SubjectRequest | The read request. |
Remarks
An immediate check is
Notify(TWatchedSubject)
Notifies all subscribed observers with the provided watched subject.
Declaration
public void Notify(TWatchedSubject _Subject)
Parameters
| Type | Name | Description |
|---|---|---|
| TWatchedSubject | _Subject | The watched subject to forward to observers. |
OnDestroy()
Stops the monitor when the underlying
Declaration
protected virtual void OnDestroy()
OnPause()
Called when the monitor is paused. Override to provide custom pause behavior.
Declaration
protected virtual void OnPause()
OnResume()
Called when the monitor is resumed. Override to provide custom resume behavior.
Declaration
protected virtual void OnResume()
OnStart()
Called when the monitor is started. Override to provide custom start behavior.
Declaration
protected virtual void OnStart()
OnStop()
Called when the monitor is stopped. Override to provide custom stop behavior.
Declaration
protected virtual void OnStop()
OnUpdate()
Called on each Unity update while the monitor is started, not paused and active. Override to implement custom update behavior.
Declaration
protected virtual void OnUpdate()
Pause()
Pauses the monitor, temporarily suspending data collection without terminating it.
Declaration
public void Pause()
Resume()
Resumes the monitor after a pause.
Declaration
public void Resume()
Start()
Starts the monitor, beginning data collection and processing.
Declaration
public void Start()
Remarks
An inactive monitor stays stopped, so OnStart() does not publish.
Stop()
Stops the monitor and finalizes any cleanup.
Declaration
public void Stop()
Subscribe(IObserver<TWatchedSubject>)
Subscribes an observer to receive notifications from the monitor.
Declaration
public IDisposable Subscribe(IObserver<TWatchedSubject> _Observer)
Parameters
| Type | Name | Description |
|---|---|---|
| IObserver<TWatchedSubject> | _Observer | The observer to subscribe. |
Returns
| Type | Description |
|---|---|
| IDisposable | An |
WaitForForceRead()
Waits one short slice while ForceRead() is blocked on a request that is not done yet.
Declaration
protected virtual bool WaitForForceRead()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|