Ejemplo n.º 1
0
def ChangeState(lCurState, lNxtState, window, windView, EntManager):
    """This function is passed a couple lists representing the info on the different levels of this game's
    hierarchical finite state machine. This function essentially generically sets up the Entity and Asset Managers
    based off of data that can be retreived from xml files.
    @param lCurState This list contains the information on which state the program is in and it takes acount into
        sub-states. So each element of the list is a sub-state of the previous element.
    @param lNxtState This list contains the information on which state the program is to be switched to and it takes acount into
        sub-states. So each element of the list is a sub-state of the previous element.
    @param windView This is SFML's View object and allows us to zoom in on the what would be shown in the window. This
        essentially just gives us the option to zoom in on the stuff visible for a certain state (can be specified in xml data.)
    @param EntManager This is the entity manager and is for loading entities into the game based on the state being switched to.
        The xml data tells which entities need to be loaded for what state."""

    print "NEW STATE!", lNxtState
    #The data will lie within the nextState[0]+".txt" file and the nextState[1] element within that elemthe ent.
    tree = parse("StateData/%s/%s.xml"%(lNxtState[0],lNxtState[1]))
    
    #The root element and the element containing the entities we need will be using this variable.
    root = tree.getroot()


    #This will reset the windowView's dimensions within the actual window with respect to the new state
    #windView.reset(sf.FloatRect((window.width - int(root.find('viewWidth').text))/2, \
    #            (window.height - int(root.find('viewHeight').text))/2,   \
    #            int(root.find('viewWidth').text),    \
    #            int(root.find('viewHeight').text)))

    #print float(root.find('viewWidthRatio').text)

    print "The new view's stats:\nx:%f\ny:%f\nwidth:%f\nheight:%f"%(int(window.width - int(window.width*float(root.find('viewWidthRatio').text)))/2,     \
                                int(window.height - int(window.height*float(root.find('viewHeightRatio').text)))/2,  \
                                int(window.width*float(root.find('viewWidthRatio').text)),                           \
                                int(window.height*float(root.find('viewHeightRatio').text)))
    
    windView.reset(sf.FloatRect((window.width - int(window.width*float(root.find('viewWidthRatio').text)))/2,     \
                                (window.height - int(window.height*float(root.find('viewHeightRatio').text)))/2,  \
                                window.width*float(root.find('viewWidthRatio').text),                           \
                                window.height*float(root.find('viewHeightRatio').text)))
    
    config.Tile_Width = window.width / (config.CHUNK_TILES_WIDE*2.)
    config.Tile_Height = window.height / (config.CHUNK_TILES_HIGH*2.)

    print "TileWidth is %f and TileHeight is %f"%(config.Tile_Width, config.Tile_Height)
    print "Window dimensions are %d x %d"%(window.width, window.height)
    
    #windView.reset(sf.FloatRect(int(window.width - window.width*float(root.find('viewWidthRatio').text)/2), \
    #                int(window.height - window.height*float(root.find('viewHeightRatio').text)/2),            \
    #                int(window.width*float(root.find('viewWidthRatio').text)),               \
    #                int(window.height*float(root.find('viewHeightRatio').text))))

    #This clears all of the things that in the game since the last state
    EntManager._Empty_Entity_Containers()
    AstManager._Empty_Assets()
    Input_Manager._Empty_Inputs()
    System_Manager._Empty_Systems()

    for entity in root.findall('Entity'):

        entityInstance = GetEntityBlueprints(entity)

        EntManager._Add_Entity(entityInstance)

            
    #Each one of these nodes will be an input that will be initialized for the state that is being loaded (and a multitude of kinds.)
    for inpoot in root.findall("Input"):

        #print inpoot.attrib

        #Check to see if this input's type is a hotspot.
        if inpoot.attrib["type"] == "hotspot":
            Input_Manager._Add_Hotspot(inpoot.find("x").text, inpoot.find("y").text, inpoot.find("width").text, inpoot.find("height").text, \
                                       inpoot.find("OnPressed").find("type").text if inpoot.find("OnPressed") != None else None,    \
                                       inpoot.find("OnSelected").find("system").text if inpoot.find("OnSelected") != None else None,    \
                                       AssembleEntityInfo(inpoot, "OnSelected"), \
                                       inpoot.find("OnDeselected").find("system").text if inpoot.find("OnDeselected") != None else None,    \
                                       AssembleEntityInfo(inpoot, "OnDeselected"), \
                                       inpoot.find("OnPressed").find("system").text if inpoot.find("OnPressed") != None else None,    \
                                       AssembleEntityInfo(inpoot, "OnPressed"), \
                                       inpoot.find("OnReleased").find("system").text if inpoot.find("OnReleased") != None else None,   \
                                       AssembleEntityInfo(inpoot, "OnReleased"))

        #Check to see if thisinput's type is a action.
        elif inpoot.attrib["type"] == "key":
            #This will add a key_Listener to our Input_Manager given the attribute data from the inpoot elemenet from the xml file.
            Input_Manager._Add_Key_Listener(inpoot.find("key").text,    \
                                            inpoot.find("OnPressed").find("type").text if inpoot.find("OnPressed") != None else None,  \
                                            inpoot.find("OnPressed").find("system").text if inpoot.find("OnPressed") != None else None,   \
                                            AssembleEntityInfo(inpoot, "OnPressed"),    \
                                            inpoot.find("OnReleased").find("system").text if inpoot.find("OnReleased") != None else None,   \
                                            AssembleEntityInfo(inpoot, "OnReleased"))

        elif inpoot.attrib["type"] == "mouse":
            Input_Manager._Add_Mouse_Listener(inpoot.find("button").text,             \
                                              inpoot.find("OnPressed").find("type").text if inpoot.find("OnPressed") != None else None,  \
                                              inpoot.find("OnPressed").find("system").text if inpoot.find("OnPressed") != None else None,   \
                                              AssembleEntityInfo(inpoot, "OnPressed"),    \
                                              inpoot.find("OnReleased").find("system").text if inpoot.find("OnReleased") != None else None,   \
                                              AssembleEntityInfo(inpoot, "OnReleased"))

    #These are the systems that are relevant to this state and they will be added into the System_Queue class.
    for system in root.findall("System"):
        
        #This will load a system into the System_Queue and then it will be activated next update.
        System_Manager._Add_System(system.find("type").text, system.find("systemFunc").text,  AssembleEntityInfo(system))
        
            
    #Now we gotta update the state variables so that we aren't signaling to change states anymore
    for i in xrange(len(lCurState)):
        lCurState[i] = lNxtState[i]
        lNxtState[i] = "NULL"
Ejemplo n.º 2
0
def ChangeState(lCurState, lNxtState, window, windView, EntManager):
    """This function is passed a couple lists representing the info on the different levels of this game's
    hierarchical finite state machine. This function essentially generically sets up the Entity and Asset Managers
    based off of data that can be retreived from xml files.
    @param lCurState This list contains the information on which state the program is in and it takes acount into
        sub-states. So each element of the list is a sub-state of the previous element.
    @param lNxtState This list contains the information on which state the program is to be switched to and it takes acount into
        sub-states. So each element of the list is a sub-state of the previous element.
    @param windView This is SFML's View object and allows us to zoom in on the what would be shown in the window. This
        essentially just gives us the option to zoom in on the stuff visible for a certain state (can be specified in xml data.)
    @param EntManager This is the entity manager and is for loading entities into the game based on the state being switched to.
        The xml data tells which entities need to be loaded for what state."""

    print "NEW STATE!", lNxtState
    #The data will lie within the nextState[0]+".txt" file and the nextState[1] element within that elemthe ent.
    tree = parse("StateData/%s/%s.xml" % (lNxtState[0], lNxtState[1]))

    #The root element and the element containing the entities we need will be using this variable.
    root = tree.getroot()

    #This will reset the windowView's dimensions within the actual window with respect to the new state
    #windView.reset(sf.FloatRect((window.width - int(root.find('viewWidth').text))/2, \
    #            (window.height - int(root.find('viewHeight').text))/2,   \
    #            int(root.find('viewWidth').text),    \
    #            int(root.find('viewHeight').text)))

    #print float(root.find('viewWidthRatio').text)

    print "The new view's stats:\nx:%f\ny:%f\nwidth:%f\nheight:%f"%(int(window.width - int(window.width*float(root.find('viewWidthRatio').text)))/2,     \
                                int(window.height - int(window.height*float(root.find('viewHeightRatio').text)))/2,  \
                                int(window.width*float(root.find('viewWidthRatio').text)),                           \
                                int(window.height*float(root.find('viewHeightRatio').text)))

    windView.reset(sf.FloatRect((window.width - int(window.width*float(root.find('viewWidthRatio').text)))/2,     \
                                (window.height - int(window.height*float(root.find('viewHeightRatio').text)))/2,  \
                                window.width*float(root.find('viewWidthRatio').text),                           \
                                window.height*float(root.find('viewHeightRatio').text)))

    config.Tile_Width = window.width / (config.CHUNK_TILES_WIDE * 2.)
    config.Tile_Height = window.height / (config.CHUNK_TILES_HIGH * 2.)

    print "TileWidth is %f and TileHeight is %f" % (config.Tile_Width,
                                                    config.Tile_Height)
    print "Window dimensions are %d x %d" % (window.width, window.height)

    #windView.reset(sf.FloatRect(int(window.width - window.width*float(root.find('viewWidthRatio').text)/2), \
    #                int(window.height - window.height*float(root.find('viewHeightRatio').text)/2),            \
    #                int(window.width*float(root.find('viewWidthRatio').text)),               \
    #                int(window.height*float(root.find('viewHeightRatio').text))))

    #This clears all of the things that in the game since the last state
    EntManager._Empty_Entity_Containers()
    AstManager._Empty_Assets()
    Input_Manager._Empty_Inputs()
    System_Manager._Empty_Systems()

    for entity in root.findall('Entity'):

        entityInstance = GetEntityBlueprints(entity)

        EntManager._Add_Entity(entityInstance)

    #Each one of these nodes will be an input that will be initialized for the state that is being loaded (and a multitude of kinds.)
    for inpoot in root.findall("Input"):

        #print inpoot.attrib

        #Check to see if this input's type is a hotspot.
        if inpoot.attrib["type"] == "hotspot":
            Input_Manager._Add_Hotspot(inpoot.find("x").text, inpoot.find("y").text, inpoot.find("width").text, inpoot.find("height").text, \
                                       inpoot.find("OnPressed").find("type").text if inpoot.find("OnPressed") != None else None,    \
                                       inpoot.find("OnSelected").find("system").text if inpoot.find("OnSelected") != None else None,    \
                                       AssembleEntityInfo(inpoot, "OnSelected"), \
                                       inpoot.find("OnDeselected").find("system").text if inpoot.find("OnDeselected") != None else None,    \
                                       AssembleEntityInfo(inpoot, "OnDeselected"), \
                                       inpoot.find("OnPressed").find("system").text if inpoot.find("OnPressed") != None else None,    \
                                       AssembleEntityInfo(inpoot, "OnPressed"), \
                                       inpoot.find("OnReleased").find("system").text if inpoot.find("OnReleased") != None else None,   \
                                       AssembleEntityInfo(inpoot, "OnReleased"))

        #Check to see if thisinput's type is a action.
        elif inpoot.attrib["type"] == "key":
            #This will add a key_Listener to our Input_Manager given the attribute data from the inpoot elemenet from the xml file.
            Input_Manager._Add_Key_Listener(inpoot.find("key").text,    \
                                            inpoot.find("OnPressed").find("type").text if inpoot.find("OnPressed") != None else None,  \
                                            inpoot.find("OnPressed").find("system").text if inpoot.find("OnPressed") != None else None,   \
                                            AssembleEntityInfo(inpoot, "OnPressed"),    \
                                            inpoot.find("OnReleased").find("system").text if inpoot.find("OnReleased") != None else None,   \
                                            AssembleEntityInfo(inpoot, "OnReleased"))

        elif inpoot.attrib["type"] == "mouse":
            Input_Manager._Add_Mouse_Listener(inpoot.find("button").text,             \
                                              inpoot.find("OnPressed").find("type").text if inpoot.find("OnPressed") != None else None,  \
                                              inpoot.find("OnPressed").find("system").text if inpoot.find("OnPressed") != None else None,   \
                                              AssembleEntityInfo(inpoot, "OnPressed"),    \
                                              inpoot.find("OnReleased").find("system").text if inpoot.find("OnReleased") != None else None,   \
                                              AssembleEntityInfo(inpoot, "OnReleased"))

    #These are the systems that are relevant to this state and they will be added into the System_Queue class.
    for system in root.findall("System"):

        #This will load a system into the System_Queue and then it will be activated next update.
        System_Manager._Add_System(
            system.find("type").text,
            system.find("systemFunc").text, AssembleEntityInfo(system))

    #Now we gotta update the state variables so that we aren't signaling to change states anymore
    for i in xrange(len(lCurState)):
        lCurState[i] = lNxtState[i]
        lNxtState[i] = "NULL"
Ejemplo n.º 3
0
def GetEntityBlueprints(entityRoot):
    """This is separate from ChangeState() because this chunk needs to be able to be recursive.
    This is necessary for the Entity_List entity to be able to hold entities (which may also
    end up being Entity_Lists, Giants may work as a special Entity_List.)
    This essentially just creates Entities recursively and stores them inside of its parent Entity
    like it's an attribute.
    @param entityRoot This is an ElementTree Node object and this is where we'll
        be using to look for the attributes (which may be entities, and if so recursion is necessary.)
    @return An Entity object that contains the attributes (which may have Entities within it) that
        were specified within the main xml file for the game."""

    entity = None

    iEntityDrawPriority = -1

    if entityRoot.find("drawPriority") != None:
        iEntityDrawPriority = int(entityRoot.find("drawPriority").text)
    
    #This checks to see if there is a function that exists that will assemble this entity.
    if entityRoot.find("assembleFunc") != None:
        #This will hold all of the attributes needed to assemble the entity (using the xml files to get the data later on.)
        dEntityAttribs = {}

        #This will loop through all of the attributes for the current entity
        #   Note that this only iterates over the immediate children.
        for attrib in entityRoot.find("Attributes"):

            #Sounds are ultimately stored in the AssetManager, but pointers to those sounds are within entities.
            if attrib.tag == 'Sound':
                #THis will start a new list of Sounds if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a sound that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = AstManager._Get_Sound(attrib.attrib["name"], attrib.text)

            #Music are ultimately stored in the AssetManager, but pointers to the music is within entities.
            elif attrib.tag == 'Music':

                #THis will start a new list of Musics if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = AstManager._Get_Music(attrib.attrib['name'], attrib.text)

            #Textures are ultimately stored in the AssetManager, but pointers to those textures are within entities.
            elif attrib.tag == 'Texture':

                #THis will start a new list of Textures if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a texture that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = AstManager._Get_Texture(attrib.attrib['name'], attrib.text)

            #This is for the tileAtlas'
            elif attrib.tag == 'RenderState':

                #THis will start a new list of sf.RenderStates if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a sf.RenderState that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = AstManager._Get_Render_State(attrib.attrib['name'], attrib.text)


            #Fonts are also in the AssetManager like textures.
            elif attrib.tag == 'Font':

                #THis will start a new list of Fonts if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a font that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = AstManager._Get_Font(attrib.attrib['name'], attrib.text)

            #The Collision_Body needs a list of shapes represented by dictionaries of attribs for each shape. This
            #   assembles that data representation so that not just entity assemblers are required for collisidable entities.
            elif attrib.tag == 'CollisionBody':
                #THis will start a new list of CollisionShapes if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #This list of shapes will define the collision body.
                lShapes = []

                #Iterate through the collision shapes
                for cShape in attrib:
                    dShapeAttribs = {}

                    for shapeAttrib in cShape:
                        dShapeAttribs[shapeAttrib.tag] = shapeAttrib.text
                        
                    lShapes.append(dShapeAttribs)

                #Bodies are marked by their name and are defined by a list of shapes.
                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = lShapes

            #For storing entities within entities. This was originally for the EntityPQueue.
            elif attrib.tag == 'entity':

                #THis will start a new list of Entities if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Here's the one and only recursive call. The base case occurs
                #   when there aren't anymore nested Entities.
                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = GetEntityBlueprints(attrib)

            else:
                #Anything else will just be put in the dictionary as an attribute
                dEntityAttribs[attrib.tag] = attrib.text

        assembleFunc = ClassRetrieval.getClass(entityRoot.find('assembleFunc').text)
           
        #Here we're using the Assemble*() function associated with the name of this entity to assemble the entity so that
        #we can add it to the EntityManager.
        #And all Assemble*() functions will use the same arguments(using a dictionary to allow dynamic arguments.)
        entity = assembleFunc(entityRoot.attrib['name'], entityRoot.attrib['type'], iEntityDrawPriority, dEntityAttribs)

    else:
        #Here we will add in a default entity instance.
        entity = Entity.Entity(entityRoot.attrib['name'], entityRoot.attrib['type'], iEntityDrawPriority,{})

    #THis adds in the components that exist in the xml file for this entity (it allows custom/variations of entities to exist.)
    for component in entityRoot.findall('Component'):

        componentClass = ClassRetrieval.getClass(component.attrib['name'])

        #This will add in a component into the entity we just created.
        #And note that it is giving the component a dictionary of the data in the xml files.
        entity._Add_Component(componentClass({DataTag.tag: DataTag.text for DataTag in component}))

    return entity
Ejemplo n.º 4
0
def GetEntityBlueprints(entityRoot):
    """This is separate from ChangeState() because this chunk needs to be able to be recursive.
    This is necessary for the Entity_List entity to be able to hold entities (which may also
    end up being Entity_Lists, Giants may work as a special Entity_List.)
    This essentially just creates Entities recursively and stores them inside of its parent Entity
    like it's an attribute.
    @param entityRoot This is an ElementTree Node object and this is where we'll
        be using to look for the attributes (which may be entities, and if so recursion is necessary.)
    @return An Entity object that contains the attributes (which may have Entities within it) that
        were specified within the main xml file for the game."""

    entity = None

    iEntityDrawPriority = -1

    if entityRoot.find("drawPriority") != None:
        iEntityDrawPriority = int(entityRoot.find("drawPriority").text)

    #This checks to see if there is a function that exists that will assemble this entity.
    if entityRoot.find("assembleFunc") != None:
        #This will hold all of the attributes needed to assemble the entity (using the xml files to get the data later on.)
        dEntityAttribs = {}

        #This will loop through all of the attributes for the current entity
        #   Note that this only iterates over the immediate children.
        for attrib in entityRoot.find("Attributes"):

            #Sounds are ultimately stored in the AssetManager, but pointers to those sounds are within entities.
            if attrib.tag == 'Sound':
                #THis will start a new list of Sounds if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a sound that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][
                    attrib.attrib["name"]] = AstManager._Get_Sound(
                        attrib.attrib["name"], attrib.text)

            #Music are ultimately stored in the AssetManager, but pointers to the music is within entities.
            elif attrib.tag == 'Music':

                #THis will start a new list of Musics if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                dEntityAttribs[attrib.tag][
                    attrib.attrib["name"]] = AstManager._Get_Music(
                        attrib.attrib['name'], attrib.text)

            #Textures are ultimately stored in the AssetManager, but pointers to those textures are within entities.
            elif attrib.tag == 'Texture':

                #THis will start a new list of Textures if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a texture that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][
                    attrib.attrib["name"]] = AstManager._Get_Texture(
                        attrib.attrib['name'], attrib.text)

            #This is for the tileAtlas'
            elif attrib.tag == 'RenderState':

                #THis will start a new list of sf.RenderStates if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a sf.RenderState that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][
                    attrib.attrib["name"]] = AstManager._Get_Render_State(
                        attrib.attrib['name'], attrib.text)

            #Fonts are also in the AssetManager like textures.
            elif attrib.tag == 'Font':

                #THis will start a new list of Fonts if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Query the AssetManager for a font that is associated with this entity, then throw that into the dictionary of attributes!
                dEntityAttribs[attrib.tag][
                    attrib.attrib["name"]] = AstManager._Get_Font(
                        attrib.attrib['name'], attrib.text)

            #The Collision_Body needs a list of shapes represented by dictionaries of attribs for each shape. This
            #   assembles that data representation so that not just entity assemblers are required for collisidable entities.
            elif attrib.tag == 'CollisionBody':
                #THis will start a new list of CollisionShapes if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #This list of shapes will define the collision body.
                lShapes = []

                #Iterate through the collision shapes
                for cShape in attrib:
                    dShapeAttribs = {}

                    for shapeAttrib in cShape:
                        dShapeAttribs[shapeAttrib.tag] = shapeAttrib.text

                    lShapes.append(dShapeAttribs)

                #Bodies are marked by their name and are defined by a list of shapes.
                dEntityAttribs[attrib.tag][attrib.attrib["name"]] = lShapes

            #For storing entities within entities. This was originally for the EntityPQueue.
            elif attrib.tag == 'entity':

                #THis will start a new list of Entities if we haven't already loaded one into this entity's attributes.
                if dEntityAttribs.get(attrib.tag, None) == None:
                    dEntityAttribs[attrib.tag] = {}

                #Here's the one and only recursive call. The base case occurs
                #   when there aren't anymore nested Entities.
                dEntityAttribs[attrib.tag][
                    attrib.attrib["name"]] = GetEntityBlueprints(attrib)

            else:
                #Anything else will just be put in the dictionary as an attribute
                dEntityAttribs[attrib.tag] = attrib.text

        assembleFunc = ClassRetrieval.getClass(
            entityRoot.find('assembleFunc').text)

        #Here we're using the Assemble*() function associated with the name of this entity to assemble the entity so that
        #we can add it to the EntityManager.
        #And all Assemble*() functions will use the same arguments(using a dictionary to allow dynamic arguments.)
        entity = assembleFunc(entityRoot.attrib['name'],
                              entityRoot.attrib['type'], iEntityDrawPriority,
                              dEntityAttribs)

    else:
        #Here we will add in a default entity instance.
        entity = Entity.Entity(entityRoot.attrib['name'],
                               entityRoot.attrib['type'], iEntityDrawPriority,
                               {})

    #THis adds in the components that exist in the xml file for this entity (it allows custom/variations of entities to exist.)
    for component in entityRoot.findall('Component'):

        componentClass = ClassRetrieval.getClass(component.attrib['name'])

        #This will add in a component into the entity we just created.
        #And note that it is giving the component a dictionary of the data in the xml files.
        entity._Add_Component(
            componentClass(
                {DataTag.tag: DataTag.text
                 for DataTag in component}))

    return entity