Show / Hide Table of Contents

Class Effect<TriggerArgs>

Class designed to represent any sort of in-game effect. This could be anything from a simple physical damage effect to a heal effect or permanent effects. These might include AOE effects, damage over time effects, or even potentially a special effect that simply boosts a stat.

Inheritance
System.Object
Effect<TriggerArgs>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public abstract class Effect<TriggerArgs>

    where TriggerArgs : EffectArgs
Type Parameters
Name Description
TriggerArgs

The type of the parameter that will be specified to the Trigger(TriggerArgs) function when called.

Remarks

Effectively, the class is nothing more than a basis for the concept of something that happens, potentially instantaneously or potentially one or more times on a certain event (beginning of a turn, end of a turn, on taking damage, etc). The standard way to use the Effect class is to create a subclass of Effect, that at the very least implements the OnTrigger(TriggerArgs) function, which should accomplish whatever the effect should do when it is triggered. The subclass can specify what parameter(s) the OnTrigger function needs to take in via the class's type parameter. If multiple arguments are needed, one should create a class that subclasses EffectArgs that contains all the parameters, and the effect subclass should then take an instance of the EffectArgs subclass as the single parameter. If no arguments are needed, then one may pass null as the parameter to Trigger.

The concept of a duration is also built into the interface, and is considered to be in arbitrary units. The duration concept is designed to be used with EffectTrigger<TriggerArgs> instances, and has no effect when an effect is not utilized with an EffectTrigger. The duration is interpreted as simply the number of times the effect's Trigger(TriggerArgs)) function will be called before it will be removed from an EffectTrigger. If the effect is instantaneous, eg. it happens only when Trigger is called, on no particular event (such as a simple instant damage effect), then the duration specified in the constructor should be the static class constant INSTANT. If the effect is meant to have an infinite duration, or the effect wears off on some condition other than time passing, the duration may be set to INFINITE, and then manipulated appropriately to 0 when the effect has expired.

More explanation of Effects and EffectTriggers, and usage examples, can be found at the GoRogue documentation site here.

Constructors

| Improve this Doc View Source

Effect(String, Int32)

Constructor.

Declaration
public Effect(string name, int startingDuration)
Parameters
Type Name Description
System.String name

Name for the effect.

System.Int32 startingDuration

Starting duration for the effect.

Fields

| Improve this Doc View Source

INFINITE

The value one should specify as the effect duration for an infinite effect, eg. an effect that will never expire or whose expiration time is arbitrary (for example, based on a condition other than the passing of time).

Declaration
public static readonly int INFINITE
Field Value
Type Description
System.Int32
| Improve this Doc View Source

INSTANT

The value one should specify as the effect duaration for an instantaneous effect, eg. an effect that only occurs when Trigger is manually called, and thus cannot be added to an EffectTrigger<TriggerArgs>.

Declaration
public static readonly int INSTANT
Field Value
Type Description
System.Int32

Properties

| Improve this Doc View Source

Duration

The duration of the effect.

Declaration
public int Duration { get; set; }
Property Value
Type Description
System.Int32
Remarks

When the duration reaches 0, the Effect will be automatically removed from an EffectTrigger<TriggerArgs>. The duration can be changed from a subclass, which can be used in OnTrigger(TriggerArgs) to cause an effect to be "cancelled", eg. immediately expire, or to extend/reduce its duration.

| Improve this Doc View Source

Name

The name of the effect.

Declaration
public string Name { get; set; }
Property Value
Type Description
System.String

Methods

| Improve this Doc View Source

OnTrigger(TriggerArgs)

Implement to take whatever action(s) the effect is supposed to accomplish. This function is called automatically when Trigger(TriggerArgs) is called.

Declaration
protected abstract void OnTrigger(TriggerArgs e)
Parameters
Type Name Description
TriggerArgs e

Class containing all arguments OnTrigger(TriggerArgs) requires to function.

| Improve this Doc View Source

ToString()

Returns a string of the effect's name and duration.

Declaration
public override string ToString()
Returns
Type Description
System.String

String representation of the effect.

Overrides
System.Object.ToString()
| Improve this Doc View Source

Trigger(TriggerArgs)

Should be called on instantaneous effects to trigger the effect.

Declaration
public void Trigger(TriggerArgs args)
Parameters
Type Name Description
TriggerArgs args

Parameters that are passed to OnTrigger(TriggerArgs). Can be null.

Remarks

Any effect that has INSTANT duration or duration 0 when this function is called will still have its OnTrigger(TriggerArgs) function called.

Events

| Improve this Doc View Source

Expired

Event that fires as soon as the effect is about to expire. Fires after the OnTrigger(TriggerArgs) function has been called but before it is removed from any EffectTrigger<TriggerArgs> instances.

Declaration
public event EventHandler Expired
Event Type
Type Description
System.EventHandler

Extension Methods

Utility.Yield<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX