Struct Cooldown
public readonly struct Cooldown : ITranslationArgument, IEquatable<Cooldown>, IComparable<Cooldown>
- Implements
- Inherited Members
- Extension Methods
Constructors
Cooldown(DateTime, TimeSpan, CooldownTypeConfiguration, object?)
public Cooldown(DateTime startTime, TimeSpan duration, CooldownTypeConfiguration config, object? data)
Parameters
startTimeDateTimedurationTimeSpanconfigCooldownTypeConfigurationdataobject
Fields
FormatName
Translated ECooldownType.
public static readonly SpecialFormat FormatName
Field Value
FormatTimeLong
3 hours and 4 minutes
public static readonly SpecialFormat FormatTimeLong
Field Value
FormatTimeShort
3h 4m 20s
public static readonly SpecialFormat FormatTimeShort
Field Value
Properties
Config
Cooldown config for this cooldown.
public CooldownTypeConfiguration Config { get; }
Property Value
Data
Optional data to differentiate the cooldown.
public object? Data { get; }
Property Value
Duration
Duration of the cooldown.
public TimeSpan Duration { get; }
Property Value
StartTime
Time at which the cooldown started.
public DateTime StartTime { get; }
Property Value
Methods
CompareTo(Cooldown)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(Cooldown other)
Parameters
otherCooldownAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
ValueMeaning
Less than zero
This instance precedes
otherin the sort order.Zero
This instance occurs in the same position in the sort order as
other.Greater than zero
This instance follows
otherin the sort order.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Equals(Cooldown)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Cooldown other)
Parameters
otherCooldownAn object to compare with this object.
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetTimeLeft()
Get the total time left. Will be negative if the cooldown is expired.
public TimeSpan GetTimeLeft()
Returns
IsActive()
Check if the cooldown is still active (not expired).
public bool IsActive()
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Translate(ITranslationValueFormatter, in ValueFormatParameters)
Allows objects to define how they're translated in their own definition instead of creating a value converter.
public string Translate(ITranslationValueFormatter formatter, in ValueFormatParameters parameters)
Parameters
formatterITranslationValueFormatterparametersValueFormatParameters
Returns
TypeEquals(string?, object?)
Compare the type and data but ignore the date.
public bool TypeEquals(string? type, object? data)
Parameters
Returns
TypeEquals(Cooldown)
Compare the type and data but ignore the date.
public bool TypeEquals(Cooldown other)
Parameters
otherCooldown