Class Level
Represents a custom-made level.
Note: Due to intenal restrictions, the Level class can only represent the level that is currently loaded.
Namespace: Modding.Levels
Assembly: Assembly-CSharp.dll
Syntax
public class Level
Properties
CustomData
Custom data associated with this level.
Declaration
public XDataHolder CustomData { get; }
Property Value
Type | Description |
---|---|
XDataHolder |
Remarks
The keys for the data here are not automatically seperated by mod, a unique prefix for each mod is advisable here.
Keep in mind that one can't rely on any data begin present here, as machines may have been saved without the mod installed and should still load.
Entities
All entities placed in the level.
Declaration
public ReadOnlyCollection<Entity> Entities { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Entity> |
GlobalVariables
The variables with global scope.
Note that you cannot change variables using this, use the SetVariable method for that.
Declaration
public Dictionary<string, float> GlobalVariables { get; }
Property Value
Type | Description |
---|---|
Dictionary<String, Single> |
InternalLevel
Part of the internal representation of this object.
WARNING: This is not part of the stable API and subject to change!
Declaration
public CustomLevel InternalLevel { get; }
Property Value
Type | Description |
---|---|
CustomLevel |
InternalObject
The internal representation of this object.
WARNING: This is not part of the stable API and subject to change!
Declaration
public LevelEditor InternalObject { get; }
Property Value
Type | Description |
---|---|
LevelEditor |
Selection
The entities of this level that are currently selected by the local player.
Declaration
public ReadOnlyCollection<Entity> Selection { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Entity> |
Setup
The settings of the level.
Declaration
public LevelSetup Setup { get; }
Property Value
Type | Description |
---|---|
LevelSetup |
Methods
AddEntity(Guid, Int32, Vector3, Quaternion, Vector3, Boolean)
Declaration
public void AddEntity(Guid modId, int localId, Vector3 position, Quaternion rotation, Vector3 scale, bool showEffect = true)
Parameters
Type | Name | Description |
---|---|---|
Guid | modId | |
Int32 | localId | |
UnityEngine.Vector3 | position | |
UnityEngine.Quaternion | rotation | |
UnityEngine.Vector3 | scale | |
Boolean | showEffect |
AddEntity(Int32, Vector3, Quaternion, Vector3, Boolean)
Adds an entity to the level.
Declaration
public void AddEntity(int id, Vector3 position, Quaternion rotation, Vector3 scale, bool showEffect = true)
Parameters
Type | Name | Description |
---|---|---|
Int32 | id | Id of the entity type, as given by EntityPrefab.Id or in the ObjectTypes enums. |
UnityEngine.Vector3 | position | Position of the entity. |
UnityEngine.Quaternion | rotation | Rotation of the entity. |
UnityEngine.Vector3 | scale | Scale of the entity. |
Boolean | showEffect | Whether to show the placement visual effect. |
Remarks
Unlike PlayerMachine.AddBlock this doesn't return the added entity, but it is possible to call it on any connected instance.
Note that the Id of a modded entity can change at any point, use the overload with seperate modId and localId for reliable placement of modded entities.
You can use entries of the enums in ObjectTypes
as IDs.
GetCurrentLevel()
Get the level currently open in the level editor. Null if there is no open level.
Declaration
public static Level GetCurrentLevel()
Returns
Type | Description |
---|---|
Level |
GetEntitiesOfType(Guid, Int32)
Gets all entities of the specified modded type in the level.
Declaration
public ReadOnlyCollection<Entity> GetEntitiesOfType(Guid modId, int localId)
Parameters
Type | Name | Description |
---|---|---|
Guid | modId | Guid of the mod that adds the entity. |
Int32 | localId | Local ID of the entity within the mod. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<Entity> | Collection of entities. |
GetEntitiesOfType(Int32)
Gets all entities of the specified type in the level.
Declaration
public ReadOnlyCollection<Entity> GetEntitiesOfType(int id)
Parameters
Type | Name | Description |
---|---|---|
Int32 | id | Id of the entity type/perfab. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<Entity> | Collection of entities. |
RemoveEntity(Entity)
Removes an entity from the level.
Declaration
public void RemoveEntity(Entity entity)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity to remove. |
SetVariable(String, Single)
Set a global variable.
Declaration
public void SetVariable(string var, float val)
Parameters
Type | Name | Description |
---|---|---|
String | var | |
Single | val |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |