7 class(Rubble).float creationtime;
9 void RubbleLimit(string cname, float limit, void(entity) deleteproc)
17 // remove rubble of the same type if it's at the limit
18 // remove multiple rubble if the limit has been decreased
21 e = findchain(classname, cname);
22 if (e == world) break;
23 // walk the list and count the entities, find the oldest
24 // initialize our search with the first entity
27 oldesttime = e.creationtime;
29 // compare to all other matching entities
33 if (oldesttime > e.creationtime)
35 oldesttime = e.creationtime;
41 // stop if there are less than the limit already
42 if (c <= limit) break;
44 // delete this oldest one and search again
49 entity RubbleNew(string cname)
51 // spawn a new entity and return it
54 e.creationtime = time;