def add_entity_to_group(entity, group_name): _world = worlds.get_active_world() if entity['_id'] in _world['entity_groups'][group_name]: return False entity['_groups'].append(group_name) _world['entity_groups'][group_name].append(entity['_id'])
def add_entity_to_group(entity, group_name): _world = worlds.get_active_world() if entity["_id"] in _world["entity_groups"][group_name]: return False entity["_groups"].append(group_name) _world["entity_groups"][group_name].append(entity["_id"])
def get_entity_groups(group_names): _world = worlds.get_active_world() _entities = [] for group_name in group_names: _entities.extend(_world['entity_groups'][group_name]) return [entity_id for entity_id in _entities if entity_id in ENTITIES]
def get_entity_groups(group_names): _world = worlds.get_active_world() _entities = [] for group_name in group_names: _entities.extend(_world["entity_groups"][group_name]) return [entity_id for entity_id in _entities if entity_id in ENTITIES]
def tick(): _world = worlds.get_active_world() for entity_group in _world['entity_groups'].keys(): if entity_group in _world['static_entity_groups']: continue for entity_id in _world['entity_groups'][entity_group]: trigger_event(ENTITIES[entity_id], 'tick')
def tick(): _world = worlds.get_active_world() for entity_group in _world["entity_groups"].keys(): if entity_group in _world["static_entity_groups"]: continue for entity_id in _world["entity_groups"][entity_group]: trigger_event(ENTITIES[entity_id], "tick")
def remove_entity_from_group(entity, group_name): _world = worlds.get_active_world() if not entity["_id"] in _world["entity_groups"][group_name]: print("Trying to remove entity from a group it isn't in: %s (%s)" % (entity["_id"], group_name)) entity["_groups"].remove(group_name) return False _world["entity_groups"][group_name].remove(entity["_id"]) entity["_groups"].remove(group_name)
def remove_entity_from_group(entity, group_name): _world = worlds.get_active_world() if not entity['_id'] in _world['entity_groups'][group_name]: print('Trying to remove entity from a group it isn\'t in: %s (%s)' % (entity['_id'], group_name)) entity['_groups'].remove(group_name) return False _world['entity_groups'][group_name].remove(entity['_id']) entity['_groups'].remove(group_name)
def create_entity_group(group_name, static=False): _world = worlds.get_active_world() if group_name in _world["entity_groups"]: raise Exception("Trying to create duplicate entity group:" % group_name) _world["entity_groups"][group_name] = [] if static: _world["static_entity_groups"].add(group_name) logging.debug("Created entity group: %s" % group_name)
def create_entity_group(group_name, static=False): _world = worlds.get_active_world() if group_name in _world['entity_groups']: raise Exception('Trying to create duplicate entity group:' % group_name) _world['entity_groups'][group_name] = [] if static: _world['static_entity_groups'].add(group_name) logging.debug('Created entity group: %s' % group_name)
def get_entity_group(group_name): _world = worlds.get_active_world() return _world['entity_groups'][group_name]
def get_entity_group(group_name): _world = worlds.get_active_world() return _world["entity_groups"][group_name]