本文整理匯總了Python中PriorityQueue.PriorityQueue._Remove_Entity方法的典型用法代碼示例。如果您正苦於以下問題:Python PriorityQueue._Remove_Entity方法的具體用法?Python PriorityQueue._Remove_Entity怎麽用?Python PriorityQueue._Remove_Entity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PriorityQueue.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue._Remove_Entity方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Entity_Manager
# 需要導入模塊: from PriorityQueue import PriorityQueue [as 別名]
# 或者: from PriorityQueue.PriorityQueue import _Remove_Entity [as 別名]
class Entity_Manager(object):
def __init__(self):
#This allows access to specific entities
#sEntityType:(sEntityName:entity)
self._dEntities = {}
#This orders the entities so that the ones with the highest draw
# priority will be first in the list (highest priority is 0.)
self._pqDrawableEntities = PQ()
def _Empty_Entity_Containers(self):
"""This is for cleaning up the Entity Containers for when we need to change
the buttons for the next state."""
#If this was in C++ (Python may be fine without the proposal below)
#I think it'd be good to loop through all of the entities and give each of them to a system that would
#check to see if their component dictionaries contained a component that needs cleaned up a special way.
self._dEntities.clear()
self._pqDrawableEntities._Clear()
def _Add_Entity(self, entity):
"""This will add entities into our dictionary of lists of entities.
And it will also add the Entity to the PriorityQueue so that it can be drawn.
@param entity This should be an actual instance of the Entity class. So it
holds components and that's about it.
@param iPriority This is the draw priority for the Entity that it being
added. Zero is the highest draw priority (gets drawn first,) -1 means
the Entity doesn't need added to the PriorityQueue."""
if self._dEntities.get(entity._Get_Type(), None) == None:
#If there wasn't already a dictionary, then we'll make one
self._dEntities[entity._Get_Type()] = {}
#This will overwrite or create a new entity of the given name.
self._dEntities[entity._Get_Type()][entity._Get_Name()] = entity
#THis filters out the entities with -1 priorities to being added
# To the list of drawable Entities.
if (entity._Get_Draw_Priority() != -1):
self._pqDrawableEntities._Add_Entity(entity)
def _Remove_Entity(self, sEntityTypeName, sEntityName):
"""When an entity expires it will be removed with this."""
#This just prevents errors from occuring in the dictionary accessing.
if self._dEntities.get(sEntityTypeName,None) != None:
self._dEntities[sEntityTypeName].pop(sEntityName)
#Entities that aren't within the priority queue will be ignored.
self._pqDrawableEntities._Remove_Entity(entity._Get_Name(), entity._Get_Type())
def _Get_Entity(self, sEntityTypeName, sEntityName):
"""This is for retrieving entities from the dictionary. It so far
is only used for the System functions in the ChangeState() function."""
if self._dEntities.get(sEntityTypeName,None) != None \
and self._dEntities[sEntityTypeName].get(sEntityName,None) != None:
return self._dEntities[sEntityTypeName][sEntityName]
#If the entity wasn't found, we'll look for it within the
# containers of entities.
elif self._dEntities.get("EntityManager") != None:
for key in self._dEntities["EntityManager"].keys():
tmp = self._dEntities["EntityManager"][key]._Get_Entity(sEntityTypeName, sEntityName)
#This checks to see if the entity was in that container
if tmp != None:
return tmp
#If the entity still wasn't found, then it doesn't exist at this point in time
else:
print "EntityType: %s, EntityName: %s doesn't exist in the EntityManager's container of entities!" % (sEntityTypeName, sEntityName)
return None
def _Call_System_Func(self, sSystemFuncName, lEntities):
"""This will call a system function from the systems.py file. And it will provide the appropriate entities that are needed to be passed to the function.
This will also return a variable from the system function.
@param sSystemFuncName This is the name of the System function that is to be called.
@param lEntities This is a list of tuples containing information on the entities
that will have to be passed to the system function that is to be called. This allows
systems to act upon entities, so the components can be changed."""
#If one entity to pass to the systemFunc
#lEntities == [(sEntityType, sEntityName, sComponentName)]
#If two entities to pass to the systemFunc
#lEntities == [(sEntityType, sEntityName, sComponentName),(sEntityType, sEntityName, sComponentName)]
module = importlib.import_module('systems')
systemFunc = getattr(module, sSystemFuncName)
#I'm sure that this is suppose to be an empty list
if lEntities == []:
#.........這裏部分代碼省略.........