| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
hpl3:game:map [2015/03/12 11:26] nebej |
hpl3:game:map [2015/09/17 10:49] (current) ian.thomas [Map Transfer Area] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Map ====== | ====== Map ====== | ||
| + | |||
| + | ===== Overview ===== | ||
| + | |||
| + | === General === | ||
| + | |||
| + | This is the basic structure for a level script. It should control all level specific code. | ||
| + | |||
| + | === Callback Methods === | ||
| + | |||
| + | These are the methods that are called from the Map: | ||
| + | |||
| + | **void Setup()** \\ | ||
| + | Called every time a map is loaded. Called before OnStart\\ | ||
| + | **void OnStart()** \\ | ||
| + | Called the first time the map is loaded. Called before OnEnter\\ | ||
| + | **void OnEnter()** \\ | ||
| + | Called every time the map is loaded\\ | ||
| + | **void OnLeave()** \\ | ||
| + | Called when player leaves the map\\ | ||
| + | **void CreateData()** \\ | ||
| + | All special data needed for the map (and not saved) are created here.\\ | ||
| + | **void DestroyData()** \\ | ||
| + | All special data needed for the map (and not saved) are destroyed here.\\ | ||
| + | **void Update(float afTimeStep)** \\ | ||
| + | Called every update tick\\ | ||
| + | **void PostUpdate(float afTimeStep)** \\ | ||
| + | Called after all normal Update during a tick has been called\\ | ||
| + | **void VariableUpdate(float afDeltaTime)** \\ | ||
| + | Called right before rendering the map. Has a variable timestep. Should be used for non-gameplay code\\ | ||
| + | **void OnGui(float afTimeStep)** \\ | ||
| + | When ImGui_<nowiki>*</nowiki> functions should be called.\\ | ||
| + | **void OnAction (int alAction, bool abPressed)** \\ | ||
| + | When an action is made.\\ | ||
| + | **void OnAnalogInput(int alAnalogId, cVector3f &in avAmount)** \\ | ||
| + | When an analog action is made.\\ | ||
| + | **float DrawDebugOutput(cGuiSet @apSet,iFontData @apFont,float afStartY)** \\ | ||
| + | This only used for pure debug purposes. Use cLux_DrawDebugText(…) for easily outputting messages. “Show Map Info” in the F1 menu must be turned on for it to show up.\\ | ||
| + | **void OnRenderSolid(cRendererCallbackFunctions@ apFunctions)** \\ | ||
| + | Useful for drawing debug output or if you want some really specific effect in the level. | ||
| ====== Map Streaming ====== | ====== Map Streaming ====== | ||
| Line 31: | Line 70: | ||
| In order to make smooth transitions between levels you have to use an Map Transfer Area. This is an area that is placed around the end of map A and the begining of map B. The player and any objects inside this area will retain their state and position relative to the area. The area needs to be placed at the same relative position and have the same size in both levels. It is possible to have different rotation of the area, in cases where maps dont share the same orientation. The area also needs to have the same name on both maps. It is possible to use multiple Map Transfer Areas for maps multiple endings. | In order to make smooth transitions between levels you have to use an Map Transfer Area. This is an area that is placed around the end of map A and the begining of map B. The player and any objects inside this area will retain their state and position relative to the area. The area needs to be placed at the same relative position and have the same size in both levels. It is possible to have different rotation of the area, in cases where maps dont share the same orientation. The area also needs to have the same name on both maps. It is possible to use multiple Map Transfer Areas for maps multiple endings. | ||
| - | The state of the objects are transfered using a save state, this contains everything from position to the value of a script variable. For each object inside the area of map A the state is saved. The code then looks for a entity with the same name in map B. If the entity exists then the state is loaded, otherwise the entity is recreated on map B with a _fckg_QUOT__stream__fckg_QUOT_ suffix at the end. It is important that the area used during the transition looks the same on both maps. Otherwise the player will notice the change. This only works for Props that allow map transfer, this is true as default. Use SetAllowMapTransfer(false) to disable map transfer of a prop type. | + | The state of the objects are transfered using a save state, this contains everything from position to the value of a script variable. For each object inside the area of map A the state is saved. The code then looks for a entity with the same name in map B. If the entity exists then the state is loaded, otherwise the entity is recreated on map B with a "__stream__" suffix at the end. It is important that the area used during the transition looks the same on both maps. Otherwise the player will notice the change. This only works for Props that allow map transfer, this is true as default. Use SetAllowMapTransfer(false) to disable map transfer of a prop type. |
| The name of the Map Transfer Area needs to be passed as an argument to ChangeMap in order for it to work. | The name of the Map Transfer Area needs to be passed as an argument to ChangeMap in order for it to work. | ||
| Line 41: | Line 80: | ||
| **void Map_Deload(const tString &in asTransferArea = "")** | **void Map_Deload(const tString &in asTransferArea = "")** | ||
| + | |||
| + | ===== Stopping a prop from transferring ===== | ||
| + | |||
| + | In some cases you don't want a prop to transfer; either because you want to stop the player taking it with them, or because you don't want its properties preserved and would rather use the version in the new map. Use ''Prop_SetAllowMapTransfer ()'' at any point to mark a prop as not transferable. | ||
| ===== Changing Map ===== | ===== Changing Map ===== | ||