当前位置: 首页>>代码示例>>Python>>正文


Python Entities.load_buildings方法代码示例

本文整理汇总了Python中horizons.entities.Entities.load_buildings方法的典型用法代码示例。如果您正苦于以下问题:Python Entities.load_buildings方法的具体用法?Python Entities.load_buildings怎么用?Python Entities.load_buildings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizons.entities.Entities的用法示例。


在下文中一共展示了Entities.load_buildings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_environment

# 需要导入模块: from horizons.entities import Entities [as 别名]
# 或者: from horizons.entities.Entities import load_buildings [as 别名]
init_environment(True)

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):
开发者ID:MarkusHackspacher,项目名称:unknown-horizons,代码行数:33,代码来源:print_db_data.py


注:本文中的horizons.entities.Entities.load_buildings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。