Created
March 6, 2019 17:42
-
-
Save ribbanya/f7562097cdc2b800ce619224d3756e5d to your computer and use it in GitHub Desktop.
Entitas manual ID system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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