Class StatusEffectsSystem
Inheritance
Namespace: Content.Shared.StatusEffect
Assembly: Content.Shared.dll
Syntax
public sealed class StatusEffectsSystem : EntitySystem
Methods
| Improve this Doc View SourceCanApplyEffect(EntityUid, String, StatusEffectsComponent)
Returns whether a given entity can have a given effect applied to it.
Declaration
public bool CanApplyEffect(EntityUid uid, string key, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to check on. |
System.String | key | The status effect ID to check for |
StatusEffectsComponent | status | The status effect component, should you already have it. |
Returns
Type | Description |
---|---|
System.Boolean |
HasStatusEffect(EntityUid, String, StatusEffectsComponent)
Returns whether a given entity has the status effect active.
Declaration
public bool HasStatusEffect(EntityUid uid, string key, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to check on. |
System.String | key | The status effect ID to check for |
StatusEffectsComponent | status | The status effect component, should you already have it. |
Returns
Type | Description |
---|---|
System.Boolean |
Initialize()
Declaration
public override void Initialize()
TryAddStatusEffect(EntityUid, String, TimeSpan, Boolean, StatusEffectsComponent, Nullable<TimeSpan>)
Tries to add a status effect to an entity with a certain timer.
Declaration
public bool TryAddStatusEffect(EntityUid uid, string key, TimeSpan time, bool refresh, StatusEffectsComponent status = null, TimeSpan? startTime = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to add the effect to. |
System.String | key | The status effect ID to add. |
TimeSpan | time | How long the effect should last for. |
System.Boolean | refresh | The status effect cooldown should be refreshed (true) or accumulated (false). |
StatusEffectsComponent | status | The status effects component to change, if you already have it. |
System.Nullable<TimeSpan> | startTime | The time at which the status effect started. This exists mostly for prediction resetting. |
Returns
Type | Description |
---|---|
System.Boolean | False if the effect could not be added, or if the effect already existed. |
Remarks
This obviously does not add any actual 'effects' on its own. Use the generic overload, which takes in a component type, if you want to automatically add and remove a component.
If the effect already exists, it will simply replace the cooldown with the new one given. If you want special 'effect merging' behavior, do it your own damn self!
TryAddStatusEffect(EntityUid, String, TimeSpan, Boolean, String, StatusEffectsComponent)
Declaration
public bool TryAddStatusEffect(EntityUid uid, string key, TimeSpan time, bool refresh, string component, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | |
System.String | key | |
TimeSpan | time | |
System.Boolean | refresh | |
System.String | component | |
StatusEffectsComponent | status |
Returns
Type | Description |
---|---|
System.Boolean |
TryAddStatusEffect<T>(EntityUid, String, TimeSpan, Boolean, StatusEffectsComponent)
Tries to add a status effect to an entity, with a given component added as well.
Declaration
public bool TryAddStatusEffect<T>(EntityUid uid, string key, TimeSpan time, bool refresh, StatusEffectsComponent status = null)
where T : Component, new()
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to add the effect to. |
System.String | key | The status effect ID to add. |
TimeSpan | time | How long the effect should last for. |
System.Boolean | refresh | The status effect cooldown should be refreshed (true) or accumulated (false). |
StatusEffectsComponent | status | The status effects component to change, if you already have it. |
Returns
Type | Description |
---|---|
System.Boolean | False if the effect could not be added or the component already exists, true otherwise. |
Type Parameters
Name | Description |
---|---|
T | The component type to add and remove from the entity. |
TryAddTime(EntityUid, String, TimeSpan, StatusEffectsComponent)
Tries to add to the timer of an already existing status effect.
Declaration
public bool TryAddTime(EntityUid uid, string key, TimeSpan time, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to add time to. |
System.String | key | The status effect to add time to. |
TimeSpan | time | The amount of time to add. |
StatusEffectsComponent | status | The status effect component, should you already have it. |
Returns
Type | Description |
---|---|
System.Boolean |
TryGetTime(EntityUid, String, out Nullable<(TimeSpan, TimeSpan)>, StatusEffectsComponent)
Gets the cooldown for a given status effect on an entity.
Declaration
public bool TryGetTime(EntityUid uid, string key, out (TimeSpan, TimeSpan)? time, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to check for status effects on. |
System.String | key | The status effect to get time for. |
System.Nullable<System.ValueTuple<TimeSpan, TimeSpan>> | time | Out var for the time, if it exists. |
StatusEffectsComponent | status | The status effects component to use, if any. |
Returns
Type | Description |
---|---|
System.Boolean | False if the status effect was not active, true otherwise. |
TryRemoveAllStatusEffects(EntityUid, StatusEffectsComponent)
Tries to remove all status effects from a given entity.
Declaration
public bool TryRemoveAllStatusEffects(EntityUid uid, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to remove effects from. |
StatusEffectsComponent | status | The status effects component to change, if you already have it. |
Returns
Type | Description |
---|---|
System.Boolean | False if any status effects failed to be removed, true if they all did. |
TryRemoveStatusEffect(EntityUid, String, StatusEffectsComponent, Boolean)
Attempts to remove a status effect from an entity.
Declaration
public bool TryRemoveStatusEffect(EntityUid uid, string key, StatusEffectsComponent status = null, bool remComp = true)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to remove an effect from. |
System.String | key | The effect ID to remove. |
StatusEffectsComponent | status | The status effects component to change, if you already have it. |
System.Boolean | remComp | If true, status effect removal will also remove the relevant component. This option exists mostly for prediction resetting. |
Returns
Type | Description |
---|---|
System.Boolean | False if the effect could not be removed, true otherwise. |
Remarks
Obviously this doesn't automatically clear any effects a status effect might have. That's up to the removed component to handle itself when it's removed.
TryRemoveTime(EntityUid, String, TimeSpan, StatusEffectsComponent)
Tries to remove time from the timer of an already existing status effect.
Declaration
public bool TryRemoveTime(EntityUid uid, string key, TimeSpan time, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The entity to remove time from. |
System.String | key | The status effect to remove time from. |
TimeSpan | time | The amount of time to add. |
StatusEffectsComponent | status | The status effect component, should you already have it. |
Returns
Type | Description |
---|---|
System.Boolean |
TrySetTime(EntityUid, String, TimeSpan, StatusEffectsComponent)
Use if you want to set a cooldown directly.
Declaration
public bool TrySetTime(EntityUid uid, string key, TimeSpan time, StatusEffectsComponent status = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | |
System.String | key | |
TimeSpan | time | |
StatusEffectsComponent | status |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Not used internally; just sets it itself.
Update(Single)
Declaration
public override void Update(float frameTime)
Parameters
Type | Name | Description |
---|---|---|
System.Single | frameTime |