Created
July 6, 2014 14:52
-
-
Save mzaks/80829078d499099df7ea 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
using Entitas; | |
public class PositionComponent : IComponent { | |
public int x, y; | |
public PositionComponent(int x, int y) | |
{ | |
this.x = x; | |
this.y = y; | |
} | |
} | |
public static class PositionComponentExtension | |
{ | |
public static void AddComponent(this Entity e, PositionComponent component) | |
{ | |
e.AddComponent(CG.Position, component); | |
} | |
public static void AddPosition(this Entity e, int x, int y) | |
{ | |
e.AddComponent(new PositionComponent(x, y)); | |
} | |
public static PositionComponent GetComponentPosition(this Entity e) | |
{ | |
return (PositionComponent)e.GetComponent(CG.Position); | |
} | |
public static int GetPositionX(this Entity e) | |
{ | |
return e.GetComponentPosition().x; | |
} | |
public static int GetPositionY(this Entity e) | |
{ | |
return e.GetComponentPosition().y; | |
} | |
public static bool HasPosition(this Entity e) | |
{ | |
return e.GetComponentPosition() != null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment