public class EntityLink extends Component { @EntityId public int otherId; public int nothingHere; }
public class UniEntityIdLink extends Component { @EntityId public int field; public static class Mutator implements UniFieldMutator { @Override public int read(Component c, Field f) { return ((UniEntityIdLink) c).field; } @Override public void write(int value, Component c, Field f) { ((UniEntityIdLink) c).field = value; } @Override public void setWorld(World world) {} } }
/** * Entity aims at target entity. * * @author Daan van Yperen */ public class Aim extends Component { @EntityId public int at; public Aim(int at) { this.at = at; } public Aim() { } }
/** * Focus of entity (for example, focus for aggression). * * @author Daan van Yperen */ public class Focus extends Component { @EntityId public int entity; public Focus(int entity) { this.entity = entity; } public Focus() { } }
/** * Focus of entity (for example, focus for aggression). * * @author Daan van Yperen */ public class Focus extends Component { @EntityId public int entity; public Focus(int entity) { this.entity = entity; } public Focus() { } }
/** * Entity aims at target entity. * * @author Daan van Yperen */ public class Aim extends Component { @EntityId public int at; public Aim(int at) { this.at = at; } public Aim() { } }
/** * Accelerate entity towards target entity in a straight path. * * @author Daan van Yperen */ public class Homing extends Component { @EntityId public int target; public float speedFactor = 5f; // Distance within which this entity will accelerate. public float maxDistance = 999999f; public Homing(int target) { this.target = target; } public Homing() { } }
public class UniEntityIdLink extends Component { @EntityId public int field; public static class Mutator implements UniFieldMutator { @Override public int read(Component c, Field f) { return ((UniEntityIdLink) c).field; } @Override public void write(int value, Component c, Field f) { ((UniEntityIdLink) c).field = value; } @Override public void setWorld(World world) {} } }
/** * Accelerate entity towards target entity in a straight path. * * @author Daan van Yperen */ public class Homing extends Component { @EntityId public int target; public float speedFactor = 5f; // Distance within which this entity will accelerate. public float maxDistance = 999999f; public Homing(int target) { this.target = target; } public Homing() { } }
public class MultiEntityIdLink extends Component { @EntityId public IntBag field; public static class Mutator implements MultiFieldMutator<IntBag, MultiEntityIdLink> { private EntitySubscription all; @Override public void setWorld(World world) { all = world.getAspectSubscriptionManager().get(all()); } @Override public void validate(int sourceId, IntBag ids, LinkListener listener) { for (int i = 0; ids.size() > i; i++) { int id = ids.get(i); if (!all.getActiveEntityIds().unsafeGet(id)) { ids.remove(i--); if (listener != null) listener.onTargetDead(sourceId, id); } } } @Override public IntBag read(MultiEntityIdLink c, Field f) { return c.field; } } }
public class MultiEntityIdLink extends Component { @EntityId public IntBag field; public static class Mutator implements MultiFieldMutator<IntBag, MultiEntityIdLink> { private EntitySubscription all; @Override public void setWorld(World world) { all = world.getAspectSubscriptionManager().get(all()); } @Override public void validate(int sourceId, IntBag ids, LinkListener listener) { for (int i = 0; ids.size() > i; i++) { int id = ids.get(i); if (!all.getActiveEntityIds().unsafeGet(id)) { ids.remove(i--); if (listener != null) listener.onTargetDead(sourceId, id); } } } @Override public IntBag read(MultiEntityIdLink c, Field f) { return c.field; } } }
@EntityId public int parent;
@EntityId public int parent;
public class MultiLinkCheckAll extends Component { @EntityId @LinkPolicy(CHECK_SOURCE_AND_TARGETS) public IntBag other = new IntBag(); }