Table of Contents

Struct Cooldown

Namespace
Uncreated.Warfare.Players.Cooldowns
Assembly
Uncreated.Warfare.dll
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

startTime DateTime
duration TimeSpan
config CooldownTypeConfiguration
data object

Fields

FormatName

Translated ECooldownType.

public static readonly SpecialFormat FormatName

Field Value

SpecialFormat

FormatTimeLong

3 hours and 4 minutes

public static readonly SpecialFormat FormatTimeLong

Field Value

SpecialFormat

FormatTimeShort

3h 4m 20s

public static readonly SpecialFormat FormatTimeShort

Field Value

SpecialFormat

Properties

Config

Cooldown config for this cooldown.

public CooldownTypeConfiguration Config { get; }

Property Value

CooldownTypeConfiguration

Data

Optional data to differentiate the cooldown.

public object? Data { get; }

Property Value

object

Duration

Duration of the cooldown.

public TimeSpan Duration { get; }

Property Value

TimeSpan

StartTime

Time at which the cooldown started.

public DateTime StartTime { get; }

Property Value

DateTime

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

other Cooldown

An 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:
Value

Meaning

Less than zero

This instance precedes other in the sort order.

Zero

This instance occurs in the same position in the sort order as other.

Greater than zero

This instance follows other in the sort order.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

other Cooldown

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

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

TimeSpan

IsActive()

Check if the cooldown is still active (not expired).

public bool IsActive()

Returns

bool

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

formatter ITranslationValueFormatter
parameters ValueFormatParameters

Returns

string

TypeEquals(string?, object?)

Compare the type and data but ignore the date.

public bool TypeEquals(string? type, object? data)

Parameters

type string
data object

Returns

bool

TypeEquals(Cooldown)

Compare the type and data but ignore the date.

public bool TypeEquals(Cooldown other)

Parameters

other Cooldown

Returns

bool