namespace OECS; /// /// Describes a single change that occurred in the ECS world. /// public readonly struct EntityChange : IEquatable { /// /// The entity that was affected. /// public Entity Entity { get; } /// /// The kind of change. /// public ChangeKind Kind { get; } /// /// The component type involved, or null for entity-level changes /// ( / ). /// public Type? ComponentType { get; } internal EntityChange(Entity entity, ChangeKind kind, Type? componentType = null) { Entity = entity; Kind = kind; ComponentType = componentType; } public bool Equals(EntityChange other) { return Entity.Equals(other.Entity) && Kind == other.Kind && ComponentType == other.ComponentType; } public override bool Equals(object? obj) => obj is EntityChange other && Equals(other); public override int GetHashCode() => HashCode.Combine(Entity, Kind, ComponentType); public override string ToString() => ComponentType == null ? $"{Kind} {Entity}" : $"{Kind} {ComponentType.Name} on {Entity}"; }