Changed project name
This commit is contained in:
@@ -1,30 +1,29 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ghost.Entities;
|
||||
|
||||
[SkipLocalsInit]
|
||||
public struct Entity : IEquatable<Entity>, IComparable<Entity>
|
||||
[StructLayout(LayoutKind.Sequential, Size = 8)]
|
||||
public readonly struct Entity : IEquatable<Entity>, IComparable<Entity>
|
||||
{
|
||||
public const EntityID INVALID_ID = -1;
|
||||
|
||||
[JsonInclude]
|
||||
private EntityID _id;
|
||||
private GenerationID _generation;
|
||||
private readonly EntityID _id;
|
||||
private readonly GenerationID _generation;
|
||||
|
||||
public readonly EntityID ID
|
||||
public EntityID ID
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _id;
|
||||
}
|
||||
|
||||
public readonly GenerationID Generation
|
||||
public GenerationID Generation
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _generation;
|
||||
}
|
||||
|
||||
public readonly bool IsValid
|
||||
public bool IsValid
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => ID != INVALID_ID;
|
||||
@@ -42,27 +41,24 @@ public struct Entity : IEquatable<Entity>, IComparable<Entity>
|
||||
_generation = generation;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void IncrementGeneration() => _generation++;
|
||||
|
||||
public readonly bool Equals(Entity other)
|
||||
public bool Equals(Entity other)
|
||||
{
|
||||
return _id == other._id && _generation == other._generation;
|
||||
}
|
||||
|
||||
public readonly int CompareTo(Entity other)
|
||||
public int CompareTo(Entity other)
|
||||
{
|
||||
return _id.CompareTo(other._id);
|
||||
}
|
||||
|
||||
public override readonly bool Equals(object? obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Entity other && Equals(other);
|
||||
}
|
||||
|
||||
public override readonly int GetHashCode()
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _id.GetHashCode();
|
||||
return _id ^ _generation << 16;
|
||||
}
|
||||
|
||||
public static bool operator ==(Entity left, Entity right)
|
||||
@@ -75,8 +71,8 @@ public struct Entity : IEquatable<Entity>, IComparable<Entity>
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public override readonly string ToString()
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Entity {{ Index: {ID}, Generation: {Generation} }}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user