The Core is the first plugin in the bunch: it includes general purpose classes and utilities that are used by the other plugins and, of course, can be used by everyone.Core namespaceColors
is basically the transformation of .net's standard Color instances in ColorRgba instances, and in addition it lets you convert a Vector4 to a ColorRgba by using FromBase1Vector4
(in case your vector's components are in the range 0-1) or FromBase255Vector4
(in case they are in the range 0-255), where the vector's X, Y, Z, W are mapped to R, G, B, A components.FastMath
is a helper class to improve the performances of commonly used Math functions; for the moment it only contains a FastFloor
is the Random generator as it is implemented in Mono; after testing, it appeared that the previous Xor-shift based approach had in fact become slower than the default Random implementation of the latest versions of .net. To my surprise, Mono's implementation is even faster than that.
Being a derived class from Random, all the extensions included in Duality apply to this class as well.MultiSpacePoint
is a struct used extensively by the UI plugin to manage Widgets. It's simply used to keep track of a point coordinates in different spaces (Scene space, World space, and UV space). Don't know if it could be useful outside of the plugin, but it's there.Utilities
, as the name implies, contains a bunch of general-purpose methods. At the moment it contains a IsDualityEditor
property to determine if the plugin is currently being executed inside the Editor, and a DrawCross
method to draw a cross using Canvas (since it was removed in Duality).Core.Commands namespace
Commands are a group of classes that work in conjunction with the Commander
Component in order to assign, you guessed it, Commands, to a GameObject. These Commands are executed in sequence by the Commander they are assigned to and can be synchronized between GameObject by using specific control Commands.
Commands can be simple Command
s or TimedCommand
s. The difference is that Commands are executed immediately and terminate in the frame they are started, while TimedCommands take a number of frames to complete their execution. This duration can be set absolutely, or it can depend on the desired speed and "length" of the Command.
The list of Commands available for now is:
- ColorizeSprite: timed - changes the ColorTint of a SpriteRenderer until the desired Color is reached.
- Destroy: instantaneous - destroys the GameObject.
- Move: timed - moves the GameObject to the desired absolute or relative position.
- Rotate: timed - rotates the GameObject to the desired absolute or relative angle.
- Scale: timed - scales the GameObject to the desired absolute or relative (to itself) scale factor.
- Signal: instantaneous - sets a flag to the Commander, so that it can be read by other Commanders for synchronization purposes.
- Wait: timed - does nothing for the desired time.
- WaitFor: timed - does nothing until the target Commander sets the correct Signal flag, or the target Commander has no more Commands to execute.
In addition, a ParallelCommand
can be used to perform a number of Commands at the same time, with the exception of Wait, WaitFor or ParallelCommands; the ParallelCommand is considered complete when all its subcommands are complete.
New Commands can be added by deriving the base Command or TimedCommand class.Core.Components namespace
There are a number of Components available, though not all of them are actually useful at the moment.BaseInputReceiver
are two abstract classes that can be used in conjunction with InputController
to directly control a GameObject using Keyboard and Mouse events. The selection of the GameObject to control is currently done via Camera Picking so it's not exactly the best solution, although it doesn't have a huge impact on the performances.Commander
, as described before, is the component in charge of managing Commands.VisualTreeHider
is a Component that can Activate or Deactivate all ICmpRenderers
in the Scene tree, starting from the GameObject where it is instanced at; it can be used, for example, to show or hide an entire branch of the Scene without travelling it by hand. Note that all the other Components in the tree remain active so that they can continue with their execution.Core.Data namespaceRange
s are a group of classes deriving from the base Range class, made with the goal to allow you to specify a Min-Max range of values for the following types: IntegerRange
. Once a Range is instanced, you can use it to get a random value inside the Range, or a lerp (linearly interpolated) value, given a key between 0 and 1.Map<K, V>
is a generic data structure modeled as a double dictionary where each key-value pair can be searched both by Key or Value. Of course this means that both the Keys set and Values set must contain only unique values.Core.Extensions namespace
Here there are a number of extensions methods available such as:
- Camera.FadeTo: creates a fade effect to the Camera by adding a rectangular SpriteRenderer at the Camera's FocusDistance and making it fade from one color to the other (i.e. fade from Black to Transparent to fade in, from Transparent to Black to fade out); the sprite is destroyed afterwards.
- Camera.FocusOn: alters the Camera's XY position and FocusDist in order to show all the desired area in the screen's viewport. Camera's Z remains fixed.
- Camera.LookAt: alters the Camera's XYZ position in order to show all the desired area in the screen's viewport. Requires the target Z position.
- ColorRgba.ToFloatArray: converts the color to an array of float whose values are in the range 0...1.
- ColorRgba.ToVector4: converts the color to a Vector4 whose values are in the range 0...255.
- GameObject.FindAncestorWithComponent<T>: returns the first ancestor in the Scene tree with a Component of type T or null if not found.
- OpenTK.Rect.Expand: returns a Rect whose sides were extended by the specified amount in each direction.
Contains utility classes to model Circles
; mostly used in the procedural plugin.