Skip to content

Commit

Permalink
gen & id
Browse files Browse the repository at this point in the history
  • Loading branch information
andreakarasho committed Mar 3, 2024
1 parent a648357 commit 5757af6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/EntityView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,30 @@ internal EntityView(World world, EcsID id)
ID = id;
}

public EcsID Generation => IDOp.GetGeneration(ID);
public EcsID RealID => IDOp.RealID(ID);


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(EcsID other) => ID == other;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(EntityView other) => ID == other.ID;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override int GetHashCode() => ID.GetHashCode();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly override bool Equals(object? obj) => obj is EntityView ent && Equals(ent);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly EntityView Set<T>() where T : struct
{
World.Set<T>(ID);
return this;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly EntityView Set<T>(T component) where T : struct
{
World.Set(ID, component);
Expand All @@ -62,34 +69,43 @@ public readonly EntityView Set<T>(T component) where T : struct
// return this;
// }

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly EntityView Unset<T>() where T : struct
{
World.Unset<T>(ID);
return this;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly EntityView Enable()
{
World.Unset<EcsDisabled>(ID);
return this;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly EntityView Disable()
{
World.Set<EcsDisabled>(ID);
return this;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<EcsComponent> Type() => World.GetType(ID);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ref T Get<T>() where T : struct => ref World.Get<T>(ID);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Has<T>() where T : struct => World.Has<T>(ID);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void Delete() => World.Delete(ID);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Exists() => World.Exists(ID);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool IsEnabled() => !Has<EcsDisabled>();


Expand Down

0 comments on commit 5757af6

Please sign in to comment.