Skip to content

Instantly share code, notes, and snippets.

@ribbanya
Created March 6, 2019 17:42
Show Gist options
  • Save ribbanya/f7562097cdc2b800ce619224d3756e5d to your computer and use it in GitHub Desktop.
Save ribbanya/f7562097cdc2b800ce619224d3756e5d to your computer and use it in GitHub Desktop.
Entitas manual ID system
using Entitas.CodeGeneration.Attributes;
public static class EntityHelper {
public static T CreateEntityWithId<T>(this Context<T> @this) where T : class, IIdEntity, IEntity {
var entity = @this.CreateEntity();
entity.AddId(entity.creationIndex);
return entity;
}
}
[Engine, Debug, Draw, InputDevice]
public sealed class IdComponent : Entitas.IComponent {
[PrimaryEntityIndex] public int Value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment