SelectTool - Megasploot/Dungeondraft GitHub Wiki

Overview

The tool used to select objects. Inherits from Tool.

Accessed by Global.Editor.Tools["SelectTool"].

Properties

Array<Node2D> Selected

Gets an array of things selected by the user. A special function exposed a beautified version of the selection to mod scripts.

 

Dictionary<Node2D, int> Selectables

Gets a dictionary of things selected by the user. A special function exposed a beautified version of the selection to mod scripts. The key are the selected things and the int is the type of selected thing.

Reference the following enum to identify a selected type. The enumeration is internal to Dungeondraft and becomes an int when it enters your script.

enum SelectableTypes
{
    Invalid = 0
    Wall = 1
    PortalFree = 2
    PortalWall = 3
    Object = 4
    Pathway = 5
    Light = 6
    PatternShape = 7
    Roof = 8
}

 

Array<Selectable> RawSelectables

Gets an array of unbeautified Selectable. It is a sub-class which allows the SelectTool to safely select and manipulate asset instances. When a SelectTool modifies a selection, Selectable is the real class that is used. A Selectable has three properties:

Node2D Thing
int Type
bool IsInGroup

 

Dictionary<String, bool> Filter

Gets a Dictionary of filtered types chosen by the user. Can be modified. Use this property if you intend to check if the user does not want to select certain types. The following are valid String keys to check.

  • Walls
  • Portals
  • Objects
  • Paths
  • Lights
  • Patterns
  • Roofs

 

Dictionary<int, bool> LayerFilter

Gets a Dictionary of filtered asset layers chosen by the user. Can be modified. Use this property if you intend to check if the user does not want to select things in certain layers. The following are valid layer number keys to check.

  • 9999
  • -400
  • -100
  • 100
  • 200
  • 300
  • 400
  • 700
  • 900

 

Functions

void SelectThing(Node2D thing, bool value)

External version of Select to allow safe select and deselecting of things. Automatically creates an internal Selectable if it does not exist. You will want to call Global.Editor.Toolset.GetToolPanel("SelectTool").OnSelect(type) if you want the Select Tool panel to display the controls that allow the user to edit the selected type.

 

void SelectThingsInsideBox(Rect2 box)

Select things inside the Rect2 in world space while respecting any current filters.

 

void Delete()

Deletes all selected things.

 

bool IsDeletable(Selectable s)

Returns true if the Selectable s is a deletable type

 

void DeselectAll()

Removes all things from selection. Call ClearTransformSelection() instead if you want to also clear the selection box visuals.

 

int GetSelectableType(Node thing)

Gets the SelectableType of the thing.

 

Selectable GetSelectable(Node2D thing)

Gets the Selectable of a thing. Only works for things already inside the selection. Otherwise, use Select(Node2D thing).

 

void EnableTransformBox(bool value)

Turns on and off the selection box visuals.

 

void ClearTransformSelection()

Deselects all things and also removes the selection box visuals.

 

Rect2 GetSelectionRect()

Returns a Rect2 that encloses all selected things. This is the function also called internally by SelectTool just after a user draws a box.

 

void RotateTransformBox(float rotation)

Rotates every thing that can be rotated in degrees by the center of the box.

 

void MirrorTransformBox()

Horizontally flip all transformable things along center of the box.

 

void Lock()

Toggles the lock on selected things. Use carefully, as the user may not realize you locked their asset instances.

 

bool IsSelectionLocked()

Returns true if the first thing the user selected is locked.

 

void MakePrefab()

Prompts the user to make the current selection into a prefab.

 

void Separate()

Separate the current selected prefab into individual pieces and disassociating with the prefab.

 

void MergeWalls()

Merges walls if there are more than one wall selected that can be merged. Incompatible with a selection of mixed types.

 

⚠️ **GitHub.com Fallback** ⚠️