Autoload Script
SandInfo
Inherits: Object
This Autoload script is where the Cell and Chunk classes are defined and stored, as well as the plugin version and some static element information.
Static Methods
| Return Type | Method |
|---|---|
| ElementStorage | GetElementResource() |
| void | SaveElementStorage() |
| Array[StringName] | GetElementFlags() |
| Array[String] | GetElementFlagsAsString() |
| int | CellPosToChunkPos() |
| void | UpdateCloseChunks() |
| void | SwapCells() |
| void | OnUpdate(Cell cell, PowderSimulation simRef) |
Properties
| Type | Property |
|---|---|
| String | PluginVersion |
| Enum | ElementTypes |
| Enum | ElementFlags |
Constants
| Type | Property |
|---|---|
| String | ElementResourcePath |
| Vector2I | TOPLEFT |
| Vector2I | TOPMIDDLE |
| Vector2I | TOPRIGHT |
| Vector2I | LEFTMIDDLE |
| Vector2I | RIGHTMIDDLE |
| Vector2I | BOTTOMLEFT |
| Vector2I | BOTTOMMIDDLE |
| Vector2I | BOTTOMRIGHT |
Static Method Descriptions
ElementStorage GetElementResource()
Returns the current ElementStorage resource where all element information is stored.
void SaveElementStorage()
Saves the current ElementStorage resource to ElementResourcePath.
Array[StringName] GetElementFlags()
Returns ElementFlags as a Godot Array of StringNames.
Array[String] GetElementFlagsAsString()
Returns ElementFlags as a Godot Array of Strings.
int CellPosToChunkPos(Vector2I cellPos, int chunkSize)
Vector2I cellPos- The local simulation position of the cell to convert.int chunkSize- The size of the axis of a single chunk, e.g. 64.
Returns cellPos translated into its local chunk index (aka the index of the cell inside the chunks's cell array).
void UpdateCloseChunks(Cell cell, PowderSimulation simRef)
SandInfo.Cell cell- The cell to use to find the correct chunk to update.PowderSimulationsimRef- A reference to the PowderSimulation Node for the current simulation.
If Cell is on the edge of its chunk, wakes the chunk nearest to the cell.
void SwapCells(Cell copyCell, Cell pasteCell)
SandInfo.Cell copyCell- The first cell to swap.SandInfo.Cell pasteCell- The second cell to swap.
Swaps the variables necessary to carry ove when moving cells. Parameter order does not matter.
void OnUpdate(Cell cell, PowderSimulation simRef)
SandInfo.Cell cell- The cell to update.PowderSimulationsimRef- A reference to the PowderSimulation Node for the current simulation.
Runs the reactions, and then the movement of the specified cell in the simulation.
Property Descriptions
String PluginVersion
The current version of this plugin being used.
Enum ElementTypes
The possible types an element can be classified as.
| Values | Description |
|---|---|
| STATIC | An unmoving element. |
| SOLID | A moving element that can pass through LIQUID and GAS elements. |
| LIQUID | A moving element that can pass through GAS elements. |
| GAS | A moving element that cannot pass through any element types. |
Enum ElementFlags
The possible flags an element can have attached to it to give it special interactions and properties.
| Values | Description |
|---|---|
| FLAMMABLE | This element can be set on fire. |
| ACID_RESISTANT | This element cannot be destroyed by the ACID default element. |
| INDESTRUCTIBLE | This element cannot be destroyed by another element as part of its reaction. |
Constant Descriptions
String ElementResourcePath
= "res://addons/powder_engine/PowderedWorldEngine/ElementData.tres"
The path to the saved ElementStorage resource in the FileSystem.
Vector2I TOPLEFT
= Vector2I(-1, -1)
The vector to add to the position of a cell to find its top-left neighbor.
Vector2I TOPMIDDLE
= Vector2I(0, -1)
The vector to add to the position of a cell to find its top-middle neighbor.
Vector2I TOPRIGHT
= Vector2I(1, -1)
The vector to add to the position of a cell to find its top-right neighbor.
Vector2I LEFTMIDDLE
= Vector2I(-1, 0)
The vector to add to the position of a cell to find its left-middle neighbor.
Vector2I RIGHTMIDDLE
= Vector2I(1, 0)
The vector to add to the position of a cell to find its right-middle neighbor.
Vector2I BOTTOMLEFT
= Vector2I(-1, 1)
The vector to add to the position of a cell to find its bottom-left neighbor.
Vector2I BOTTOMMIDDLE
= Vector2I(0, 1)
The vector to add to the position of a cell to find its bottom-middle neighbor.
Vector2I BOTTOMRIGHT
= Vector2I(1, 1)
The vector to add to the position of a cell to find its bottom-right neighbor.