7 class(Rubble).float creationtime;
9 void RubbleLimit(string cname, float limit, void(entity) deleteproc)
11 // remove rubble of the same type if it's at the limit
12 // remove multiple rubble if the limit has been decreased
15 // walk the list and count the entities, find the oldest
16 // initialize our search with the first entity
20 // compare to all other matching entities
21 FOREACH_ENTITY_CLASS(cname, true,
24 if(!oldest || oldesttime > it.creationtime)
27 oldesttime = it.creationtime;
31 // stop if there are less than the limit already
32 if (c <= limit) break;
34 // delete this oldest one and search again
39 entity RubbleNew(string cname)
41 // spawn a new entity and return it
44 e.creationtime = time;