@Override public int read(Component c, Field f) { Entity e = ((UniEntityLink) c).field; return (e != null) ? e.getId() : -1; }
@SuppressWarnings("unchecked") protected T editEntity(Entity entity) { this.entity = entity; this.edit = entity.edit(); return (T) this; }
public static float distance2( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pa.xy.x, pa.xy.y).dst2(pb.xy.x, pb.xy.y); }
output.writeInt(e.getId()); return; } else { world.getComponentManager().getComponentsFor(e.getId(), components); components.sort(comparator); output.writeInt(e.getCompositionId());
@Override protected void process(Entity e) { Schedule schedule = sm.get(e); schedule.age += world.delta; final Array<Step> steps = schedule.steps; for (int i = 0; i < steps.size; i++) { final Step step = steps.get(i); if (schedule.age >= step.atAge && step.act(world.delta, e) && i < steps.size) { steps.removeIndex(i); step.release(); i--; if ( !e.isActive() ) return; } } if (schedule.steps.size == 0 && e.isActive() ) { e.edit().remove(Schedule.class); } } }
@Override public void process(Entity e) { e.deleteFromWorld(); } }
private void writeArchetype(Json json, Entity e) { json.writeValue("archetype", e.getCompositionId()); }
@Override public boolean process(float delta, Entity e) { if (!completed && e.isActive()) { if ( operation.process(delta,e) ) { completed = (desiredRepetitions != UNLIMITED) && (++repetition >= desiredRepetitions); if ( !completed ) { operation.rewind(); } } } return completed; }
/** * Returns whether this Aspect would accept the given Entity. */ public boolean isInterested(Entity e){ return isInterested(e.getComponentBits()); }
public static Entity create(World world, int entityId) { return new Entity(world, entityId); } }
boolean contains = e.getSystemBits().get(systemIndex); boolean interested = true; // possibly interested, let's try to prove it wrong. Bits componentBits = e.getComponentBits();
output.writeInt(e.getId()); return; } else { world.getComponentManager().getComponentsFor(e.getId(), components); components.sort(comparator); output.writeInt(e.getCompositionId());
@Override public boolean act(float delta, Entity e) { e.deleteFromWorld(); return true; }
private void writeArchetype(Json json, Entity e) { json.writeValue("archetype", e.getCompositionId()); }
@Override public boolean process(float delta, Entity e) { if (!completed && e.isActive()) { if ( operation.process(delta,e) ) { completed = (desiredRepetitions != UNLIMITED) && (++repetition >= desiredRepetitions); if ( !completed ) { operation.rewind(); } } } return completed; }
/** * Returns whether this Aspect would accept the given Entity. */ public boolean isInterested(Entity e){ return isInterested(e.getComponentBits()); }
@Override protected Entity newObject() { return new Entity(world); }
/** * Create or remove a component from an entity. * * Does nothing if already removed or created respectively. * * @param entity Entity to change. * @param value {@code true} to create component (if missing), {@code false} to remove (if exists). * @return the instance of the component, or {@code null} if removed. */ public A set(Entity entity, boolean value) { return set(entity.getId(), value); }