コード例 #1
0
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'])
コード例 #2
0
ファイル: entities.py プロジェクト: witheld9/r3-tdw
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"])
コード例 #3
0
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]
コード例 #4
0
ファイル: entities.py プロジェクト: witheld9/r3-tdw
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]
コード例 #5
0
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')
コード例 #6
0
ファイル: entities.py プロジェクト: witheld9/r3-tdw
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")
コード例 #7
0
ファイル: entities.py プロジェクト: witheld9/r3-tdw
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)
コード例 #8
0
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)
コード例 #9
0
ファイル: entities.py プロジェクト: witheld9/r3-tdw
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)
コード例 #10
0
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)
コード例 #11
0
def get_entity_group(group_name):
    _world = worlds.get_active_world()

    return _world['entity_groups'][group_name]
コード例 #12
0
ファイル: entities.py プロジェクト: witheld9/r3-tdw
def get_entity_group(group_name):
    _world = worlds.get_active_world()

    return _world["entity_groups"][group_name]