本文整理汇总了Python中horizons.entities.Entities.load_units方法的典型用法代码示例。如果您正苦于以下问题:Python Entities.load_units方法的具体用法?Python Entities.load_units怎么用?Python Entities.load_units使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.entities.Entities
的用法示例。
在下文中一共展示了Entities.load_units方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_obj_name
# 需要导入模块: from horizons.entities import Entities [as 别名]
# 或者: from horizons.entities.Entities import load_units [as 别名]
import horizons.main
from horizons.constants import UNITS, BUILDINGS, TIER
from horizons.scenario.actions import ACTIONS
from horizons.scenario.conditions import CONDITIONS
db = horizons.main._create_main_db()
# we also need to load entities to get access to the yaml data
from horizons.extscheduler import ExtScheduler
from horizons.component.storagecomponent import StorageComponent
from horizons.entities import Entities
from tests.dummy import Dummy
ExtScheduler.create_instance(Dummy()) # sometimes needed by entities in subsequent calls
Entities.load_buildings(db, load_now=True)
Entities.load_units(load_now=True)
building_name_mapping = dict((b.id, b.name) for b in Entities.buildings.itervalues())
unit_name_mapping = dict((u.id, u.name) for u in Entities.units.itervalues())
def get_obj_name(obj):
global db
if obj < UNITS.DIFFERENCE_BUILDING_UNIT_ID:
return db("SELECT name FROM building where id = ?", obj)[0][0]
else:
return unit_name_mapping[obj]
def get_res_name(res):
global db