Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
This page describes some of the inner workings of the tilesystem
In order to create a new tilesystem, you need to create a new GameObject in a scene and add the following scripts:
TileSystem
TileResourceLoader
Furthermore in order to use the creator, you will need to add the ConstructionMenu prefab to the scene.
When playing in runtime, the TileSystem will automatically try to load a saved tilemap from the StreamingAssets folder and recreate it using ScriptableObjects found by the TileResourceLoader.
When placed, the tilemap uses the following structure to keep track of all tiles. Ranked in order from the lowest element to the highest:
PlacedItemObject - This script is attached to every itemthat is spawned on the map. Ensures spawning/despawning and is always attached to a GameObject.
PlacedTileObject - This script is attached to every object that is spawned on the map. Ensures spawning/despawning and holds references to any adjacency connectors. Always attached to a GameObject.
TileObject - This class represents a single object on a single layer and can contain one PlacedTileObject. So for each tile position in the world, there is are (number of layers) amount of TileObjects. Not attached to a GameObject.
TileChunk - A chunk represents a 16 by 16 grid of TileObjects for each layer (16 x 16 x num of layers). Chunks are not really used at the moment, but have to potential to benefit networking and loading for massive maps in the future. Created as a GameObject as a parent to PlacedTileObjects.
TileMap - Holds a dictionary of chunks filled with TileObjects and a list of PlacedItemObjects. The later are not position bound so are not part of a chunk. Created as a GameObject as a parent to chunks and items.
TileSystem - The system to hold TileMaps, and serves as the main interaction point to place and remove items/tiles. Only a single instance of the TileSystem can exist.
TileResourceLoader - Reads and holds the ScriptableObjects for each item and tile that can be placed. Used by the TileSystem to figure out what object is placed.
Saved-X-Object - Used to hold the state of the corresponding class/struct and is serializable. Used for saving and loading.
BuildChecker - Used to validate combinations of placed objects and can check whether an object can be placed. For example, no objects can be build on the Turf layer if a Plenum is missing.
SaveSystem - Generic save system that is used for saving and loading of the tilemap from and to a file. Uses the StreamingAssets folder so that builds also receive it.
TileMapCreator - Used as an in-game editor for placing and removing tiles/items and saving/loading. Is networked so that clients are also able to work on the map.
GhostManager - Used for construction as part of the TileMapCreator to create a "ghost" object to see where you are building.
MultiAdjacencyConnector - Used for connecting walls and tables together. Keeps track of which neighbours it is connected to and will replace and rotate meshes accordingly.
Functions and features of the tilemap system.
For mapping design see the Maps Design document linked below.
The tilemap system forms the basis of the space station and is responsible for the creation and management of all items and 2-dimensional tiles that compose the station. Every static object such as floors, walls and bolted objects (i.e., fixtures) are part of the tilemap. Other systems such as construction or atmospherics have a close integration with the tilemap.
Grid-based design with chunks The new design leverages collections more, which allows us to go faster through objects that are on the same layer. Next to that, the map is divided into chunks of 16 x 16 tiles. This should allow more flexibility in the future in cases where we only need to look at objects nearby, without the need to go through the entire map.
Saving and loading The tilemap is now fully serialized and can be saved and loaded at will. This allows a few options like the ability to save chaotic stations at the end of a round for other game modes, but will also make resolving merge conflicts in the map easier.
Multi-tile objects Objects that are bigger than a single tile can now be successfully added to the map. You can now place a cryo tube again without having to worry about it colliding with other nearby objects.
Items Items are now part of the tilemap and can be placed and removed. This means that they are also part of the save system.
The design of the system can be found in the the link below.
Adjacency connections refers to when a tilemap object is connectable to its neighbors, walls being the typical example of this.
In order to make walls and tables connect to each other, you need to make use of a adjacency connector. This keeps track of which neighbours it is connected to and will replace and rotate meshes accordingly.
There are different types of adjacencies supported right now.
Simple - Used for simple connections without a lot of use cases. Covers the basic shapes such as I, U, O, T and X.
Advanced - Expansion of the Simple type with a lot more edge cases covered.
Offset - Used for meshes which are not placed in the middle (thus offset). Used by pipes for example.
Disposal Furniture - checks if connected from above to a disposal pipe. Very specific one.
Disposal Pipe - Used for disposal pipes only.
Door - Specific to doors, because of the specific way it connects to other doors and to walls.
Pipe - For pipes with an offset (not centered on the tile)
The first thing you need is to implement the IAdjacencyConnector interface.
If your tile object connects only with things from the same layer, adjacent to it, you might want to look at the AbstractHorizontalConnector class and inherit from it.
It will only ask you to implement the IsConnected() method, as it varies a lot from one connector to another. Door, simple, advanced, offset, pipe all inherits from it. Chances your connector could too.
If the connections are weirder, such as disposal pipes able to connect to disposal furniture, a different object on a different layer, with a different connector, and with special behavior when it connects, then directly implement the IAdjacencyConnector interface.
Add the right adjacency connector script to your prefab's root game object. You can recognise a Connector script because it implements the IAdjacencyConnector interface. To know which specific script to use, check the connectables design pages.
Connectable scripts usually ask you to add specific mesh for specific configurations. You need to fill them all up for the connector to work properly.
Check the Connectables design page for more informations about your specific connector and how the meshes should look.
Also know that the connectables scripts assume the mesh you link are rotated in a specific fashion, otherwise they may appear incorrectly in game. If you have this issue of meshes badly rotated, try to rotate the models you use, out of the game.
Alain suggested spatial hashing to network big quantities of objects.
Using the tilemap creator.
To get started with the creator, run the game and press B after spawning. This will bring the creator menu up.
Press left mouse button to place an object
Press R to rotate an object
Hold left shift to replace an existing object on the same layer
Click drag to place/delete/replace in a line form
Alt+Click drag to place/delete/replace in a square form
Each tile can hold multiple objects on different layers. The following layers are implemented:
Plenums - These form the foundations of the station. Always required to be present before another layer can be build
Turfs - Walls and floors go on this layer
Wires - High, medium and low voltage wires
Disposal - Disposal pipes fit in this layer
Pipes - Atmospheric pipes go here
WallMountHigh - Wall mounts that are placed high on the wall
WallMountLow - Wall mounts that are placed low on the wall
FurnitureBase - Regular objects such as chairs, tables and counters go here
FurnitureTop - Objects that go on top of FurnitureBase. For example desk lamps
Overlays - Indicators that fit on top of floors go here
To add a new item or object to the tilemap system, a new scriptableobject needs to be created.
Make sure to save the item/tile ScriptableObjects under the corresponding "Content/Data/TileMap/Resources/" folder
The following information can be filled in for a TileObjectSo:
Name String - describes the name of the object
Prefab - which prefab to spawn
Icon - Icon which is used by the creator and construction interface
Layer - which layer the item should be put in
Generic Type - Generics types are used to categorize objects on the same layer. Used by the adjacency connector to connect walls for example
Specific Type - Specific types are used to specify the material that the object is made of. For example used by carpets to ensure that they don't connect to other floors
Width - width of the object. Used for multi-tile objects
Height - height of the object. Used for multi-tile objects
Items can be added in a similar way:
Make sure the Name String is unique. Not doing so will create issues during loading & saving.
Well, bare in mind that this is the design idea, which we haven't executed yet:
Simply the button to exit the map editor.
This menu contains all the tools to edit the tilemap, and has the following tools:
Select
Move around with the mouse.
Edit
Uses the selected object in the object menu with a place hint of the position.
Move (with mouse)
Move an object precisely (only for non-tile-locked objects)
Undo
Undo
Redo
Redo
Quicksave
Saves your map on a list of quicksaves.
Open map selection
Opens a better saving/loading menu
This menu contains all options relating to menu, HUD and view modes.
Reset position to 0
Resets the camera position, zoom, and rotation to the initial values.
Layer view mode
Hide determined layers.
Hide UI
Screenshot friendly feature.
Camera options
FOV options, camera speed, rotation speed.
Map editor settings
Keymap settings, debug options.
The map editing modes are menus to select the list of objects that can be selected to place:
Upper
Lower
Items
Scripting & Placements
Spawn placements, random item spawners, triggers.
Flooring
Turfs
Doors
TileObjects
Wall Attachments
Piping
Disposals
Base tiles
Items. Bananas, sodas, janicarts.
Spawn placements
Random item spawners
Triggers.
This menu contains the selected list of objects based on the map editing modes and subcategories.
Panel containing a search bar to search usign tags, names or keywords