Last active
May 26, 2017 03:46
-
-
Save FNGgames/950e1dedbef189778806fabfc332489e to your computer and use it in GitHub Desktop.
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
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