-
Notifications
You must be signed in to change notification settings - Fork 0
Content providers
Miguel Gonzalez edited this page Sep 24, 2013
·
8 revisions
Content providers provide content for chunk systems (sounds simple, doesn't it?) - let's take over the spaceship example and create a class, called Universe. This universe contains multiple space ships. Let us begin with a simple implementation:
public class Universe implements ContentProvider, Updatetable {
private List<Object> targets;
public Universe() {
targets = new ArrayList<Object>();
}
@Override
public void remove(Object target) {
targets.remove(target);
}
@Override
public void add(Object target) {
targets.add(target);
}
@Override
public Collection<Object> getContent() {
return targets;
}
@Override
public void update() {
for (Object target : targets) {
if (target instanceof Updatetable) {
((Updatetable)target).update();
}
}
}
}That's it! It's on your own to render the world in a seperate class. Now you have met all conditions to work with chunk systems.