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


Python Entity._Get_Component方法代码示例

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


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

示例1: Assemble_Chunk_Manager

# 需要导入模块: from Entity import Entity [as 别名]
# 或者: from Entity.Entity import _Get_Component [as 别名]
def Assemble_Chunk_Manager(sEntityName, sEntityType, iDrawPriority, attribDict):
    """This will return an Entity object that contains a list of lists of lists of tiles,
    some world coordinates, the number of chunks in the screen, and all that stuff that is
    needed in order to manager a chunks of tiles (except for the textures, those are already
    taken care of.)"""
    entity = Entity(sEntityName, sEntityType, iDrawPriority, {})

    if attribDict["ChunkDataDir"] == "SavedGame":
        #Notice that the ChunkDataDir is prefixed by the directory that this file is in.
        entity._Add_Component(getClass("Misc")({"componentID":"ChunkDataDir", "storage":os.getcwd()+config.Saved_Game_Directory}))

    elif attribDict["ChunkDataDir"] == "MapEdi":
        #Notice that the ChunkDataDir is prefixed by the directory that this file is in.
        entity._Add_Component(getClass("Misc")({"componentID":"ChunkDataDir", "storage":os.getcwd()+config.Map_Data_Directory}))    

    else:
        #Notice that the ChunkDataDir is prefixed by the directory that this file is in.
        entity._Add_Component(getClass("Misc")({"componentID":"ChunkDataDir", "storage":os.getcwd()+attribDict["ChunkDataDir"]}))

    entity._Add_Component(getClass("Position")({"componentID":"WorldPos", "positionX":attribDict["WorldPos"].split(',')[0], "positionY":attribDict["WorldPos"].split(',')[1]}))
    entity._Add_Component(getClass("Position")({"componentID":"ChunksInWind", "positionX":attribDict["ChunksInWind"].split(",")[0], "positionY":attribDict["ChunksInWind"].split(",")[1]}))
    entity._Add_Component(getClass("Flag")({"componentID":"VisibilityUpdate", "flag":False}))

    entity._Add_Component(getClass("Dictionary")({"componentID":"ChunkDict"}))

    List = getClass("List")

    entity._Add_Component(List({"componentID":"LoadList"}))
    entity._Add_Component(List({"componentID":"RebuildList"}))
    entity._Add_Component(List({"componentID":"UnloadList"}))
    entity._Add_Component(List({"componentID":"FlagList"}))
    entity._Add_Component(getClass("Render_List")({"componentID":"RenderList"}))

    #This is so that new chunks can be given a pointer to the tile atlas' for the tiles' textures.
    entity._Add_Component(getClass("Misc")({"componentID":"TileAtlas", "storage":attribDict["RenderState"].items()}))

    lWorldPos = attribDict["WorldPos"].split(",")

    lChunksInWindow = attribDict["ChunksInWind"].split(",")

    Assemble_Chunk = getClass("Assemble_Chunk")


    #This will strictly assemble the chunks around the outside of the chunks on the screen (the first items in the loadList get loaded last, so we add these first!)
    #This only will loop through the chunks to the left and right of the screen.
    for i in xrange( int(lWorldPos[0])-1, int(lWorldPos[0]) + int(lChunksInWindow[0])+1 ):
        for j in xrange( int(lWorldPos[1])-1, int(lWorldPos[1]) + int(lChunksInWindow[1])+1, int(lChunksInWindow[1])+1 ):

            dChunkData = {"WorldPos":"%d,%d"%(i,j), \
                          "WindowPos":str(i - int(lWorldPos[0]))+","+str(j - int(lWorldPos[1]))}

            #print "(%d,%d) is the chunk being added"

            #Iterating through the dictionary of Texture items within
            #   an element of the attribDict. These textures are
            #   the tileAtlas' and are for the Chunks Mesh component.
            for (attribName, attrib) in attribDict["RenderState"].items():
                
                #This checks to see if the current item is
                #   for the Mesh component.
                if attribName[0:9] == "TileAtlas":
                    #This will add in the Texture objects
                    #   defined by SFMl. This Texture object
                    #   points to a Texture object within
                    #   the AssetManager.
                    dChunkData[attribName] = attrib
                          
                else:
                    print "The TileAtlas' were given an incorrect name within the xml for the Chunk Manager entity."


            entity._Get_Component("DICT:ChunkDict")._Add( "%d,%d"%(i,j),                        \
                                                          Assemble_Chunk( "%s,%s" % (i, j),     \
                                                                          "Chunk",              \
                                                                          iDrawPriority,        \
                                                                          dChunkData ) )

            pChunk = entity._Get_Component("DICT:ChunkDict")._Get("%d,%d"%(i,j))

            #print "(%d,%d) is being added to the loadlist"%(i,j)

            entity._Get_Component("LIST:LoadList")._Add(pChunk)

    #This does the same thing as the previous loop, but with different chunks (above the screen and below the screen.)
    for i in xrange( int(lWorldPos[0])-1, int(lWorldPos[0]) + int(lChunksInWindow[0])+1, int(lChunksInWindow[0])+1 ):
        for j in xrange( int(lWorldPos[1]), int(lWorldPos[1]) + int(lChunksInWindow[1])):

            dChunkData = {"WorldPos":"%d,%d"%(i,j), \
                          "WindowPos":str(i - int(lWorldPos[0]))+","+str(j - int(lWorldPos[1]))}

            #Iterating through the dictionary of Texture items within
            #   an element of the attribDict. These textures are
            #   the tileAtlas' and are for the Chunks Mesh component.
            for (attribName, attrib) in attribDict["RenderState"].items():
                #This checks to see if the current item is
                #   for the Mesh component.
                if attribName[0:9] == "TileAtlas":
                    #This will add in the Texture objects
                    #   defined by SFMl. This Texture object
                    #   points to a Texture object within
#.........这里部分代码省略.........
开发者ID:WaffleTime,项目名称:TileGame,代码行数:103,代码来源:Assemble_Chunk_Manager.py


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