Class WorldStream
Data stream that handles map data from file to instance
Implements
Constructors
WorldStream(string)
Data stream that handles map data from file to instance
Declaration
public WorldStream(string mapFolder)
Parameters
Type | Name | Description |
---|---|---|
string | mapFolder | Root path of the map folder |
Properties
IsDirty
True if there's unsaved block change
Declaration
public bool IsDirty { get; }
MapRoot
Path of the map root folder
Declaration
public string MapRoot { get; init; }
UseBuiltInAsFailback
True if load file from built-in map folder when no map founded in MapRoot
Declaration
public bool UseBuiltInAsFailback { get; set; }
Methods
ClearWorldPool()
Clear internal data pool
Declaration
public void ClearWorldPool()
DiscardAllChanges(bool)
Load changed map from file
Declaration
public void DiscardAllChanges(bool forceDiscard = false)
Parameters
Type | Name | Description |
---|---|---|
bool | forceDiscard | True if perform this action no matter stream is dirty of not |
GetAllBlocksAt(int, int, int)
Get all ID of blocks at given unit position
Declaration
public (int level, int bg, int entity, int element) GetAllBlocksAt(int unitX, int unitY, int z)
Parameters
Type | Name | Description |
---|---|---|
int | unitX | Position in unit space |
int | unitY | Position in unit space |
int | z | Z position |
GetBlockAt(int, int, int, BlockType)
Get block ID at given unit position
Declaration
public int GetBlockAt(int unitX, int unitY, int z, BlockType type)
Parameters
Type | Name | Description |
---|---|---|
int | unitX | Position in unit space |
int | unitY | Position in unit space |
int | z | Position Z |
BlockType | type | Type of the block |
GetOrCreateStreamFromPool(string)
Get an instance of WorldStream. Create new one if not exists in pool.
Declaration
public static WorldStream GetOrCreateStreamFromPool(string mapFolder)
Parameters
Type | Name | Description |
---|---|---|
string | mapFolder | Root path of the map folder |
GetOrCreateWorld(int, int, int)
Get world instance on given world position. Create new one if not found.
Declaration
public World GetOrCreateWorld(int worldX, int worldY, int worldZ)
Parameters
Type | Name | Description |
---|---|---|
int | worldX | Position of world bottom-left in world space (1 world space = 256 * 128 global space) |
int | worldY | Position of world bottom-left in world space (1 world space = 256 * 128 global space) |
int | worldZ | Position Z |
Returns
Type | Description |
---|---|
World | Result world instance |
ResetFailbackCopying()
Make all existing user maps require reload from built-in maps without deleting the user map folder
Declaration
public void ResetFailbackCopying()
SaveAllDirty()
Save all block changes into file
Declaration
public void SaveAllDirty()
SetBlockAt(int, int, int, BlockType, int)
Set block ID at given unit position
Declaration
public void SetBlockAt(int unitX, int unitY, int z, BlockType type, int value)
Parameters
Type | Name | Description |
---|---|---|
int | unitX | Position in unit space |
int | unitY | Position in unit space |
int | z | Position Z |
BlockType | type | Type of the block |
int | value | ID of the block |
TryGetWorld(Int3, out World)
Get world instance on given world position
Declaration
public bool TryGetWorld(Int3 worldPos, out World world)
Result world instance
Returns
Type | Description |
---|---|
bool | True if world founded |
TryGetWorld(int, int, int, out World)
Get world instance on given world position
Declaration
public bool TryGetWorld(int worldX, int worldY, int worldZ, out World world)
Parameters
Type | Name | Description |
---|---|---|
int | worldX | Position of world bottom-left in world space (1 world space = 256 * 128 global space) |
int | worldY | Position of world bottom-left in world space (1 world space = 256 * 128 global space) |
int | worldZ | Position Z |
World | world | Result world instance |
Returns
Type | Description |
---|---|
bool | True if world founded |
WorldExists(Int3)
True if world exists at given world position
Declaration
public bool WorldExists(Int3 worldPos)
Parameters
Type | Name | Description |
---|---|---|
Int3 | worldPos | In world space (1 world space = 256 * 128 global space) |
Events
OnWorldCreated
Invoke when a world instance created
Declaration
public static event Action<WorldStream, World> OnWorldCreated
OnWorldLoaded
Invoke when a world instance loaded from file
Declaration
public static event Action<WorldStream, World> OnWorldLoaded
OnWorldSaved
Invoke when a world instance saved to file
Declaration
public static event Action<WorldStream, World> OnWorldSaved