diff --git a/src/gaemstone/ECS/EntityBuilder.cs b/src/gaemstone/ECS/EntityBuilder.cs index 2dc3846..be80477 100644 --- a/src/gaemstone/ECS/EntityBuilder.cs +++ b/src/gaemstone/ECS/EntityBuilder.cs @@ -53,7 +53,7 @@ public class EntityBuilder { // If adding a ChildOf relation, store the parent separately. if (id.AsPair(Universe) is (EntityRef relation, EntityRef target) && - relation == Universe.ChildOf) { _parent = target; return this; } + (relation == Universe.ChildOf)) { _parent = target; return this; } if (_toAdd.Count == 31) throw new NotSupportedException( "Must not add more than 31 IDs at once with EntityBuilder"); diff --git a/src/gaemstone/ECS/EntityRef.cs b/src/gaemstone/ECS/EntityRef.cs index 4ef24f4..9fb41bd 100644 --- a/src/gaemstone/ECS/EntityRef.cs +++ b/src/gaemstone/ECS/EntityRef.cs @@ -153,7 +153,7 @@ public unsafe sealed class EntityRef public EntityRef? GetTarget(int index = 0) => GetTarget(Universe.LookupOrThrow(typeof(T)), index); - public bool Equals(EntityRef? other) => (other is not null) && Universe == other.Universe && Entity == other.Entity; + public bool Equals(EntityRef? other) => (other is not null) && (Universe == other.Universe) && (Entity == other.Entity); public override bool Equals(object? obj) => Equals(obj as EntityRef); public override int GetHashCode() => HashCode.Combine(Universe, Entity); public override string? ToString() => ecs_entity_str(Universe, this).FlecsToStringAndFree()!; diff --git a/src/gaemstone/ECS/Identifier.cs b/src/gaemstone/ECS/Identifier.cs index fc7e8dc..b157a4f 100644 --- a/src/gaemstone/ECS/Identifier.cs +++ b/src/gaemstone/ECS/Identifier.cs @@ -23,8 +23,8 @@ public readonly struct Identifier public static Identifier Pair(Entity relation, Entity target) => Combine(IdentifierFlags.Pair, new( - (relation.Value.Data << 32) | - (target.Value.Data & ECS_ENTITY_MASK))); + ((relation.Value.Data << 32) & ECS_COMPONENT_MASK) | + ( target.Value.Data & ECS_ENTITY_MASK ))); public (EntityRef Relation, EntityRef Target)? AsPair(Universe universe) => new IdentifierRef(universe, this).AsPair(); diff --git a/src/gaemstone/ECS/IdentifierRef.cs b/src/gaemstone/ECS/IdentifierRef.cs index dcac415..82b7de7 100644 --- a/src/gaemstone/ECS/IdentifierRef.cs +++ b/src/gaemstone/ECS/IdentifierRef.cs @@ -28,7 +28,7 @@ public unsafe class IdentifierRef public (EntityRef Relation, EntityRef Target)? AsPair() => IsPair ? (Universe.LookupOrThrow(ID.RelationUnsafe), Universe.LookupOrThrow(ID.TargetUnsafe)) : null; - public bool Equals(IdentifierRef? other) => (other is not null) && Universe == other.Universe && ID == other.ID; + public bool Equals(IdentifierRef? other) => (other is not null) && (Universe == other.Universe) && (ID == other.ID); public override bool Equals(object? obj) => Equals(obj as IdentifierRef); public override int GetHashCode() => HashCode.Combine(Universe, ID); public override string? ToString() => ecs_id_str(Universe, this).FlecsToStringAndFree()!;