Skip to content

Instantly share code, notes, and snippets.

@FNGgames
Last active May 26, 2017 03:46
Show Gist options
  • Save FNGgames/950e1dedbef189778806fabfc332489e to your computer and use it in GitHub Desktop.
Save FNGgames/950e1dedbef189778806fabfc332489e to your computer and use it in GitHub Desktop.
void Start()
{
// ...
_contexts.game.OnEntityCreated += AddId;
_contexts.input.OnEntityCreated += AddId;
// ...
}
private void AddId(IContext context, IEntity entity)
{
GameEntity gameEntity = entity as GameEntity;
if (gameEntity != null) gameEntity.AddId(gameEntity.creationIndex);
InputEntity inputEntity = entity as InputEntity;
if (inputEntity != null) inputEntity.AddId(inputEntity.creationIndex);
}
public class IdComponent : IComponent
{
[PrimaryEntityIndex]
public int value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment