Show / Hide Table of Contents

Class DamageSpecifier

This class represents a collection of damage types and damage values.

Inheritance
System.Object
DamageSpecifier
Namespace: Content.Shared.Damage
Assembly: Content.Shared.dll
Syntax
public sealed class DamageSpecifier : IEquatable<DamageSpecifier>
Remarks

The actual damage information is stored in DamageDict. This class provides functions to apply resistance sets and supports basic math operations to modify this dictionary.

Constructors

| Improve this Doc View Source

DamageSpecifier()

Constructor that just results in an empty dictionary.

Declaration
public DamageSpecifier()
| Improve this Doc View Source

DamageSpecifier(DamageSpecifier)

Constructor that takes another DamageSpecifier instance and copies it.

Declaration
public DamageSpecifier(DamageSpecifier damageSpec)
Parameters
Type Name Description
DamageSpecifier damageSpec
| Improve this Doc View Source

DamageSpecifier(DamageGroupPrototype, FixedPoint2)

Constructor that takes a single damage group prototype and a damage value. The value is divided between members of the damage group.

Declaration
public DamageSpecifier(DamageGroupPrototype group, FixedPoint2 value)
Parameters
Type Name Description
DamageGroupPrototype group
FixedPoint2 value
| Improve this Doc View Source

DamageSpecifier(DamageTypePrototype, FixedPoint2)

Constructor that takes a single damage type prototype and a damage value.

Declaration
public DamageSpecifier(DamageTypePrototype type, FixedPoint2 value)
Parameters
Type Name Description
DamageTypePrototype type
FixedPoint2 value

Properties

| Improve this Doc View Source

DamageDict

Main DamageSpecifier dictionary. Most DamageSpecifier functions exist to somehow modifying this.

Declaration
public Dictionary<string, FixedPoint2> DamageDict { get; set; }
Property Value
Type Description
Dictionary<System.String, FixedPoint2>
| Improve this Doc View Source

Empty

Whether this damage specifier has any entries.

Declaration
public bool Empty { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Total

Sum of the damage values.

Declaration
public FixedPoint2 Total { get; }
Property Value
Type Description
FixedPoint2
Remarks

Note that this being zero does not mean this damage has no effect. Healing in one type may cancel damage in another. For this purpose, you should instead use TrimZeros() and then check the Empty property.

Methods

| Improve this Doc View Source

ApplyModifierSet(DamageSpecifier, DamageModifierSet)

Reduce (or increase) damages by applying a damage modifier set.

Declaration
public static DamageSpecifier ApplyModifierSet(DamageSpecifier damageSpec, DamageModifierSet modifierSet)
Parameters
Type Name Description
DamageSpecifier damageSpec
DamageModifierSet modifierSet
Returns
Type Description
DamageSpecifier
Remarks

Only applies resistance to a damage type if it is dealing damage, not healing.

| Improve this Doc View Source

ApplyModifierSets(DamageSpecifier, IEnumerable<DamageModifierSet>)

Reduce (or increase) damages by applying multiple modifier sets.

Declaration
public static DamageSpecifier ApplyModifierSets(DamageSpecifier damageSpec, IEnumerable<DamageModifierSet> modifierSets)
Parameters
Type Name Description
DamageSpecifier damageSpec
IEnumerable<DamageModifierSet> modifierSets
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Clamp(FixedPoint2, FixedPoint2)

Clamps each damage value to be within the given range.

Declaration
public void Clamp(FixedPoint2 minValue, FixedPoint2 maxValue)
Parameters
Type Name Description
FixedPoint2 minValue
FixedPoint2 maxValue
| Improve this Doc View Source

ClampMax(FixedPoint2)

Sets all damage values to be at most some number. Note that if a damage type is not present in the dictionary, these will not be added.

Declaration
public void ClampMax(FixedPoint2 maxValue)
Parameters
Type Name Description
FixedPoint2 maxValue
| Improve this Doc View Source

ClampMin(FixedPoint2)

Sets all damage values to be at least as large as the given number.

Declaration
public void ClampMin(FixedPoint2 minValue)
Parameters
Type Name Description
FixedPoint2 minValue
Remarks

Note that this only acts on damage types present in the dictionary. It will not add new damage types.

| Improve this Doc View Source

Equals(DamageSpecifier)

Declaration
public bool Equals(DamageSpecifier other)
Parameters
Type Name Description
DamageSpecifier other
Returns
Type Description
System.Boolean
| Improve this Doc View Source

ExclusiveAdd(DamageSpecifier)

This adds the damage values of some other DamageSpecifier to the current one without adding any new damage types.

Declaration
public void ExclusiveAdd(DamageSpecifier other)
Parameters
Type Name Description
DamageSpecifier other
Remarks

This is used for DamageableComponents, such that only "supported" damage types are actually added to the component. In most other instances, you can just use the addition operator.

| Improve this Doc View Source

GetDamagePerGroup(IPrototypeManager)

Returns a dictionary using ID keys, with values calculated by adding up the values for each damage type in that group

Declaration
public Dictionary<string, FixedPoint2> GetDamagePerGroup(IPrototypeManager protoManager = null)
Parameters
Type Name Description
Robust.Shared.Prototypes.IPrototypeManager protoManager
Returns
Type Description
Dictionary<System.String, FixedPoint2>
Remarks

If a damage type is associated with more than one supported damage group, it will contribute to the total of each group. If no members of a group are present in this DamageSpecifier, the group is not included in the resulting dictionary.

| Improve this Doc View Source

TrimZeros()

Remove any damage entries with zero damage.

Declaration
public void TrimZeros()
| Improve this Doc View Source

TryGetDamageInGroup(DamageGroupPrototype, out FixedPoint2)

Add up all the damage values for damage types that are members of a given group.

Declaration
public bool TryGetDamageInGroup(DamageGroupPrototype group, out FixedPoint2 total)
Parameters
Type Name Description
DamageGroupPrototype group
FixedPoint2 total
Returns
Type Description
System.Boolean
Remarks

If no members of the group are included in this specifier, returns false.

Operators

| Improve this Doc View Source

Addition(DamageSpecifier, DamageSpecifier)

Declaration
public static DamageSpecifier operator +(DamageSpecifier damageSpecA, DamageSpecifier damageSpecB)
Parameters
Type Name Description
DamageSpecifier damageSpecA
DamageSpecifier damageSpecB
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Division(DamageSpecifier, FixedPoint2)

Declaration
public static DamageSpecifier operator /(DamageSpecifier damageSpec, FixedPoint2 factor)
Parameters
Type Name Description
DamageSpecifier damageSpec
FixedPoint2 factor
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Division(DamageSpecifier, Single)

Declaration
public static DamageSpecifier operator /(DamageSpecifier damageSpec, float factor)
Parameters
Type Name Description
DamageSpecifier damageSpec
System.Single factor
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Multiply(DamageSpecifier, FixedPoint2)

Declaration
public static DamageSpecifier operator *(DamageSpecifier damageSpec, FixedPoint2 factor)
Parameters
Type Name Description
DamageSpecifier damageSpec
FixedPoint2 factor
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Multiply(DamageSpecifier, Single)

Declaration
public static DamageSpecifier operator *(DamageSpecifier damageSpec, float factor)
Parameters
Type Name Description
DamageSpecifier damageSpec
System.Single factor
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Multiply(FixedPoint2, DamageSpecifier)

Declaration
public static DamageSpecifier operator *(FixedPoint2 factor, DamageSpecifier damageSpec)
Parameters
Type Name Description
FixedPoint2 factor
DamageSpecifier damageSpec
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Multiply(Single, DamageSpecifier)

Declaration
public static DamageSpecifier operator *(float factor, DamageSpecifier damageSpec)
Parameters
Type Name Description
System.Single factor
DamageSpecifier damageSpec
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

Subtraction(DamageSpecifier, DamageSpecifier)

Declaration
public static DamageSpecifier operator -(DamageSpecifier damageSpecA, DamageSpecifier damageSpecB)
Parameters
Type Name Description
DamageSpecifier damageSpecA
DamageSpecifier damageSpecB
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

UnaryNegation(DamageSpecifier)

Declaration
public static DamageSpecifier operator -(DamageSpecifier damageSpec)
Parameters
Type Name Description
DamageSpecifier damageSpec
Returns
Type Description
DamageSpecifier
| Improve this Doc View Source

UnaryPlus(DamageSpecifier)

Declaration
public static DamageSpecifier operator +(DamageSpecifier damageSpec)
Parameters
Type Name Description
DamageSpecifier damageSpec
Returns
Type Description
DamageSpecifier
  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾