Skip to main content

Zones and LoadFlags

Zones

A Zone is a square area of a Tilemap which is internally represented by a RectInt. The X and Y sizes are the same and are the Chunk Size. So, for Tilemap Groups using a Chunk Size of, say, 16, each Zone is 16 x 16 tiles. Hence, the layout of all the Zones on a Tilemap acts as a sort of Super- or Higher-order grid.

LoadFlags

LoadFlags control specific aspects of the loading process. They are of flag Enum type FabOrBundleLoadFlags.

/// <summary>
/// Options for LoadTileFab and LoadBundle                                                  
/// </summary>                                                                              
[Flags]                                                                                     
public enum FabOrBundleLoadFlags                                                            
{                                                                                           
    /// <summary>                                                                           
    /// No flags used.                                                                      
    /// </summary>                                                                          
    None = 0,    
    /// <summary>
    /// Use this in a TSceneSpec to indicate clearing all the Selector flags.
    /// </summary>
    OverrideNone = 4096,                                                                           
    /// <summary>                                                                           
    /// Load Prefabs. Normally true                                                         
    /// </summary>                                                                          
    LoadPrefabs = 1,                                                                        
    /// <summary>                                                                           
    /// Clear Prefabs. Normally false                                                       
    /// </summary>                                                                          
    ClearPrefabs = 2,                                                                       
    /// <summary>                                                                           
    /// Clear Tilemap. Normally false                                                       
    /// </summary>                                                                          
    ClearTilemap = 4,                                                                       
    /// <summary>                                                                           
    /// Force Refresh. Normally false.                                                      
    /// </summary>                                                                          
    ForceRefresh = 8,                                                                       
    /// <summary>                                                                           
    /// New GUIDs for TilePlus tiles. Normally true                                         
    /// </summary>                                                                          
    NewGuids = 16,                                                                          
    /// <summary>                                                                           
    /// Apply filtering only to TilePlus tiles. Normally true                               
    /// </summary>                                                                          
    FilterOnlyTilePlusTiles = 32,                                                           
    /// <summary>                                                                           
    /// Do not clone TPT tiles in TpTileBundle.Tileset                                      
    /// </summary>                                                                          
    NoClone = 64,                                                                           
    /// <summary>                                                                           
    /// Mark a Zone Reg as immortal. Note: ONLY valid when using ZoneManager and Layouts.   
    /// </summary>                                                                          
    MarkZoneRegAsImmortal = 128,                                                            
    /// <summary>                                                                           
    /// Indicates to TileFabLib.LoadTilefab that this load is from a Chunkified bundle      
    /// and the raw tile data is already cached. Note that this doesn't include             
    /// any prefabs. Those still must be instantiated.                                      
    /// </summary>                                                                          
    Chunkified = 256,                                                                       
    /// <summary>                                                                           
    /// Most common set of options, with filtering only TPT tiles                           
    /// </summary>                                                                          
    NormalWithFilter = LoadPrefabs | NewGuids | FilterOnlyTilePlusTiles,                    
    /// <summary>                                                                           
    /// Most common set of options, with filtering for anything (if a filter is provided)   
    /// </summary>                                                                          
    Normal = LoadPrefabs | NewGuids,                                                        
    /// <summary>                                                                           
    /// Default for Chunkified loads: see TSceneList                                        
    /// </summary>                                                                          
    ChunkifiedDefault = LoadPrefabs | Chunkified | FilterOnlyTilePlusTiles                  
                                                                                            
}                                                                                           

Selectors have a field for specifying what flags to use when loading a TileFab or a section thereof.

The value of LoadFlags in the Selector is the default value for LoadFlags, but this value can be changed at other points of the processing.

When using the ChunkZoneSelector you need to use Chunkified at a bare minimum. ChunkifiedDefault is usually what you want. Note that this Selector’s Select method enforces the flag bits for Chunkified = true and NewGuids = false.

There are several ways that the LoadFlags from the Selector can be overridden on a TScene-by-TScene basis:

Each SceneSpec has a field called OverrideFlags which can be used to change these if needed for a particular TScene.

In other words, if the SceneSpec’s OverrideFlags aren’t ‘None’ then the SceneSpec’s OverrideFlags are poked into the Selector. Use OverrideNone to actually set the LoadFlags to None (OverrideNone has no meaning aside from this and shouldn’t be used except in a SceneSpec).

Note that these new values will be retained unless changed in another SceneSpec.

When using the LayoutTick method in ZoneLayout you can optionally modify these flags if you’ve provided a LoadingFilter callback. This is used in the demonstration program to mark Zones as Immortal (not removable) when an Immortalizer tile is found in a Zone.