Table of Contents

Class ConflictsWithAttribute

Namespace
KeenEyes
Assembly
KeenEyes.Abstractions.dll

Specifies that a component conflicts with another component and cannot coexist on the same entity.

[AttributeUsage(AttributeTargets.Struct, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
public sealed class ConflictsWithAttribute : Attribute
Inheritance
ConflictsWithAttribute
Inherited Members

Examples

// StaticBody and DynamicBody are mutually exclusive
[Component]
[ConflictsWith(typeof(DynamicBody))]
public partial struct StaticBody
{
    public bool IsKinematic;
}

[Component]
[ConflictsWith(typeof(StaticBody))]
public partial struct DynamicBody
{
    public float Mass;
    public float Drag;
}

Remarks

When validation is enabled, adding a component with this attribute will verify that no conflicting components are present on the entity. If a conflicting component is found, a ComponentValidationException is thrown.

Multiple ConflictsWithAttribute can be applied to the same component to express multiple conflicts. Conflicts are bidirectional - if A conflicts with B, then B implicitly conflicts with A.

Constructors

ConflictsWithAttribute(Type)

Specifies that a component conflicts with another component and cannot coexist on the same entity.

public ConflictsWithAttribute(Type conflictingType)

Parameters

conflictingType Type

The type of component that cannot coexist with this component.

Examples

// StaticBody and DynamicBody are mutually exclusive
[Component]
[ConflictsWith(typeof(DynamicBody))]
public partial struct StaticBody
{
    public bool IsKinematic;
}

[Component]
[ConflictsWith(typeof(StaticBody))]
public partial struct DynamicBody
{
    public float Mass;
    public float Drag;
}

Remarks

When validation is enabled, adding a component with this attribute will verify that no conflicting components are present on the entity. If a conflicting component is found, a ComponentValidationException is thrown.

Multiple ConflictsWithAttribute can be applied to the same component to express multiple conflicts. Conflicts are bidirectional - if A conflicts with B, then B implicitly conflicts with A.

Exceptions

ArgumentNullException

Thrown when conflictingType is null.

Properties

ConflictingType

Gets the type of the conflicting component.

public Type ConflictingType { get; }

Property Value

Type

Exceptions

ArgumentNullException

Thrown when conflictingType is null.