Game.Effects.SourceInfo
Assembly: Assembly-CSharp
Namespace: Game.Effects
Type: struct
Base: System.ValueType (implements System.IEquatable
Summary: A lightweight value type that identifies a specific effect source by pairing a Unity.Entities.Entity with an integer effect index. Used by the game's effect systems to reference which effect instance (by index) is associated with a particular entity. Equality and hashing are implemented so instances can be compared and used as keys in collections.
Fields
-
public Unity.Entities.Entity m_Entity
Represents the entity that is the source of the effect. This field is used as part of equality and hashing. -
public int m_EffectIndex
An index identifying which effect on the entity is referenced. Combined with m_Entity to uniquely identify a specific effect instance on an entity.
Properties
- None. This struct exposes public fields (m_Entity and m_EffectIndex) instead of properties.
Constructors
public SourceInfo(Unity.Entities.Entity entity, int effectIndex)
Creates a new SourceInfo with the specified entity and effect index. Parameters:- entity: The Entity that is the effect source.
- effectIndex: The index of the effect on that entity.
Methods
-
public bool Equals(SourceInfo other)
Implements IEquatable.Returns true if both m_Entity and m_EffectIndex are equal to those of other. Equality is a strict pairwise comparison (entity equality plus identical effect index). -
public override int GetHashCode()
Computes a hash code by XOR-ing the entity's hash code with the effect index. Suitable for use when SourceInfo is used as a key in hash-based collections. Note: There is no override of Equals(object) in the provided code — equality semantics via IEquatableare present, but some .NET APIs that call Equals(object) may not see the same behavior unless Equals(object) is added.
Usage Example
using Unity.Entities;
using Game.Effects;
using System.Collections.Generic;
Entity someEntity = /* obtain entity from EntityManager or system */;
int effectIdx = 0;
// Create a SourceInfo
SourceInfo src = new SourceInfo(someEntity, effectIdx);
// Compare two SourceInfo instances
SourceInfo other = new SourceInfo(someEntity, effectIdx);
bool equal = src.Equals(other); // true
// Use as a key in a Dictionary or HashSet
var set = new HashSet<SourceInfo>();
set.Add(src);
if (set.Contains(other))
{
// found the same source/effect pair
}