Loading...
Searching...
No Matches
ContainerID Interface Reference

Represents "path" from root container to specific nested object inside config hierarchy. More...

Inheritance diagram for ContainerID:
array< Class T > Managed

Public Member Functions

proto external BaseContainer GetOrCreateDirectPtr (notnull BaseContainer topLevel)
 Helper method which prepare config object for editing.
 
- Public Member Functions inherited from array< Class T >
proto native int Count ()
 O(1) complexity.
 
proto native bool IsEmpty ()
 
proto native void Clear ()
 Destroys all elements of the array and sets the Count to 0.
 
proto native void Compact ()
 Frees any underlying memory which is not used.
 
proto void Set (int n, T value)
 Sets n-th element to given value.
 
proto int Find (T value)
 Tries to find the first occurrence of value in the array.
 
proto bool Contains (T value)
 Returns whether value is in array or not.
 
proto T Get (int n)
 
proto int Insert (T value)
 Inserts element at the end of array.
 
proto int InsertAt (T value, int index)
 Inserts element at certain position and moves all elements behind this position by one.
 
void InsertAll (notnull array< T > from)
 Inserts all elements from array.
 
proto native void Remove (int index)
 Removes element from array.
 
proto native void RemoveOrdered (int index)
 Removes element from array, but retains all elements ordered.
 
proto native void Resize (int newSize)
 Resizes the array to given size.
 
proto native void Reserve (int newSize)
 Reserve memory for given number of elements.
 
proto native void Swap (notnull array< T > other)
 Swaps the contents of this and other arrays.
 
proto native void Sort (bool reverse=false)
 Sorts elements of array, depends on underlying type.
 
proto native bool IsIndexValid (int index)
 Returns whether provided element index of array is valid.
 
proto int Copy (notnull array< T > from)
 Copies contents of from array to this array.
 
proto int Init (T init[])
 
proto bool RemoveItem (T value)
 Removes element from array.
 
proto bool RemoveItemOrdered (T value)
 Removes element from array, but retain all elements ordered.
 
void Debug ()
 Print all elements in array.
 
int GetRandomIndex ()
 Returns a random index of array.
 
GetRandomElement ()
 Returns a random element of array.
 
void SwapItems (int item1_index, int item2_index)
 
- Public Member Functions inherited from Managed
proto external ref Managed Clone ()
 Return shallow copy of object, or null if it is not allowed (not public constructor)
 

Detailed Description

Represents "path" from root container to specific nested object inside config hierarchy.

Each ContainerIdPathEntry item represent one level of hierarchy, and it has:

  • PropertyName: name of Object or Object array property
  • Index: if the property defined by PropertyName is an array, index is used, otherwise leave it -1 (the default)

Let's have the following config:

Shape { // <- top level container
Points { // <- array of points
ShapePoint { // <- first element
Position 2 3 1
Metadata {
Name name1
}
}
ShapePoint { // <- second element
Position 0 1 1
Metadata { // <- for example: path to this object is: Points[1]/Metadata
Name name2
}
}
}
}
Instance of created debug visualizer.
Definition Shape.c:14

Setup ContainerID pointing to second ShapePoint Metadata:

BaseContainer rootContainer; // the root container point to "Shape"
ContainerID containerPath = {
new ContainerIdPathEntry("Points", 1), // second item in "Points" object array
new ContainerIdPathEntry("Metadata") // "Metadata" nested object of the second point
};
Definition BaseContainer.c:13
Represents "path" from root container to specific nested object inside config hierarchy.
Definition ContainerID.c:49
Definition worldEditor.c:26

Member Function Documentation

◆ GetOrCreateDirectPtr()

proto external BaseContainer ContainerID.GetOrCreateDirectPtr ( notnull BaseContainer topLevel)

Helper method which prepare config object for editing.

As nested objects or object arrays can be inherited from another config they need to be setup properly before editing.

Note
Use this method only when editing outside WorldEditor. In WorldEditor, when editing entities or components, just pass ContainerID to WorldEditorAPI.SetVariableValue and let undo stack to do the job.

Let's have an example container from ContainerID To set a Name in Metadata of the second shape point, we do:

BaseContainer rootContainer = LoadMe(); // the root container point to "Shape"
ContainerID containerPath = {
new ContainerIdPathEntry("Points", 1), // Take the second point
new ContainerIdPathEntry("Metadata") // Go to metadata of the second point
};
BaseContainer shapePoint = containerPath.GetOrCreateDirectPtr(rootContainer);
if (shapePoint)
shapePoint.Set("Name", "my new name");
SaveMe(rootContainer);
proto external bool Set(string varName, void val)
proto external BaseContainer GetOrCreateDirectPtr(notnull BaseContainer topLevel)
Helper method which prepare config object for editing.
Parameters
topLevelContainer from which the search is started.
Returns
Pointer to BaseContainer which is ready to modifications.

The documentation for this interface was generated from the following file: