Ignore:
Timestamp:
10/31/09 15:11:33 (10 years ago)
Author:
Kaydeth_parpg
Message:

Ticket #73. Patch by Kaydeth. Most of the changes were made to the map loading logic in the Engine, World, and Map classes to make sure it could handle loading maps after the game state has been restored by a load game. Also added a floating door back to both maps so map changing can still be tested in game. fixes[s:trac, t:73]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/map.py

    r340 r356  
    8080        self.map = loadMapFile(filename, self.engine, self.data) 
    8181        self.agent_layer = self.map.getLayer('ObjectLayer') 
    82  
    83         # if this is not the very first map load in the game carry over the PC instance 
    84         if self.data.target_position: 
     82         
     83        #find out if a PC instance was created when the map was loaded 
     84        found = False 
     85        for inst in self.agent_layer.getInstances(): 
     86            if inst.getId() == "PC": 
     87                found = True 
     88                break 
     89                 
     90        #If there is not a PC instance created yet than we construct the PC 
     91        #instance from what we have saved in the PC Game Object 
     92        if not found: 
    8593            x = float(self.data.target_position[0]) 
    8694            y = float(self.data.target_position[1]) 
     
    9098                                            fife.ExactModelCoordinate(x,y,z),\ 
    9199                                            "PC") 
    92             inst.setRotation(self.data.game_state.PC.behaviour.agent.getRotation()) 
    93100            fife.InstanceVisual.create(inst) 
    94  
     101        #If the PC instance exists already then make sure it's set to correct 
     102        #location for this new map 
     103        elif self.data.target_position is not None: 
     104            pos = self.data.target_position 
     105            coord = fife.DoublePoint3D(float(pos[0]), float(pos[1]), 0) 
     106            location = fife.Location(self.agent_layer) 
     107            location.setMapCoordinates(coord) 
     108            inst.setLocation(location) 
     109        #else we are loading the first map and the PC position were set by 
     110        #the coordinates in the Map file 
     111             
    95112        # it's possible there's no transition layer 
    96113        size = len('TransitionLayer') 
     
    120137                                                       strip=False))) 
    121138        rend.changeDefaultFont(text) 
    122  
     139         
    123140        # Make World aware that this is now the active map. 
    124141        self.data.view.active_map = self 
Note: See TracChangeset for help on using the changeset viewer.