Class ConstructionSystem
The server-side implementation of the construction system, which is used for constructing entities in game.
Namespace: Content.Server.Construction
Assembly: Content.Server.dll
Syntax
public sealed class ConstructionSystem : SharedConstructionSystem
Methods
| Improve this Doc View SourceAddContainer(EntityUid, String, ConstructionComponent)
Sets a container on an entity as being handled by Construction. This essentially means that it will be transferred if the entity prototype changes. Content.Server.Construction.ConstructionSystem.ChangeEntity(EntityUid,System.Nullable{EntityUid},System.String,Content.Server.Construction.Components.ConstructionComponent,System.Nullable{MetaDataComponent},System.Nullable{TransformComponent},Robust.Shared.Containers.ContainerManagerComponent)
Declaration
public bool AddContainer(EntityUid uid, string container, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
System.String | container | The container identifier. This method does not check whether the container exists. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
System.Boolean | Whether we could set the container as being handled by construction or not. Also returns false if the entity does not have a ConstructionComponent. |
ChangeGraph(EntityUid, Nullable<EntityUid>, String, String, Boolean, ConstructionComponent)
Performs a construction graph change on a construction entity, also changing the node to a valid one on the new graph.
Declaration
public bool ChangeGraph(EntityUid uid, EntityUid? userUid, string graphId, string nodeId, bool performActions = true, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
System.Nullable<EntityUid> | userUid | An optional user entity, for actions. |
System.String | graphId | The identifier for the construction graph to switch to. |
System.String | nodeId | The identifier for a node on the new construction graph to switch to. |
System.Boolean | performActions | Whether actions on the new node will be performed or not. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the construction graph change succeeded or not. Returns false if the entity does not have a ConstructionComponent. |
ChangeNode(EntityUid, Nullable<EntityUid>, String, Boolean, ConstructionComponent)
Performs a node change on a construction entity, optionally performing the actions for the new node.
Declaration
public bool ChangeNode(EntityUid uid, EntityUid? userUid, string id, bool performActions = true, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
System.Nullable<EntityUid> | userUid | An optional user entity, for actions. |
System.String | id | The identifier of the node to change to. |
System.Boolean | performActions | Whether the actions for the new node will be performed or not. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the node change succeeded or not. Also returns false if the entity does not have a ConstructionComponent. |
Remarks
This method also updates the construction pathfinding automatically, if the node change succeeds.
ClearPathfinding(EntityUid, ConstructionComponent)
Clears the pathfinding targets on a construction entity.
Declaration
public void ClearPathfinding(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
GetCurrentEdge(EntityUid, ConstructionComponent)
Gets the construction graph edge the entity is currently at, or null.
Declaration
public ConstructionGraphEdge GetCurrentEdge(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
ConstructionGraphEdge | The construction graph edge the entity is currently at, if any. Also returns null if the entity does not have a ConstructionComponent. |
Remarks
An entity with a valid construction state might not always be at an edge.
GetCurrentEdgeAndStep(EntityUid, ConstructionComponent)
Gets both the construction edge and step the entity is currently at, if any.
Declaration
public (ConstructionGraphEdge edge, ConstructionGraphStep step) GetCurrentEdgeAndStep(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
System.ValueTuple<ConstructionGraphEdge, ConstructionGraphStep> | A tuple containing the current edge and step the entity's construction state is at. |
Remarks
The edge, step or both could be null. A valid construction state does not necessarily need them.
GetCurrentGraph(EntityUid, ConstructionComponent)
Gets the current construction graph of an entity, or null.
Declaration
public ConstructionGraphPrototype GetCurrentGraph(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
ConstructionGraphPrototype | The current construction graph of an entity or null if invalid. Also returns null if the entity does not have a ConstructionComponent. |
Remarks
An entity with a valid construction state will always have a valid graph.
GetCurrentNode(EntityUid, ConstructionComponent)
Gets the construction graph node the entity is currently at, or null.
Declaration
public ConstructionGraphNode GetCurrentNode(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
ConstructionGraphNode | The current construction graph node the entity is currently at, or null if invalid. Also returns null if the entity does not have a ConstructionComponent. |
Remarks
An entity with a valid construction state will always be at a valid node.
GetCurrentNodeAndEdge(EntityUid, ConstructionComponent)
Variant of GetCurrentEdge(EntityUid, ConstructionComponent) that returns both the node and edge.
Declaration
public (ConstructionGraphNode, ConstructionGraphEdge) GetCurrentNodeAndEdge(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | |
ConstructionComponent | construction |
Returns
Type | Description |
---|---|
System.ValueTuple<ConstructionGraphNode, ConstructionGraphEdge> |
GetCurrentStep(EntityUid, ConstructionComponent)
Gets the construction graph step the entity is currently at, or null.
Declaration
public ConstructionGraphStep GetCurrentStep(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
ConstructionGraphStep | The construction graph step the entity is currently at, if any. Also returns null if the entity does not have a ConstructionComponent. |
Remarks
An entity with a valid construction state might not always be at a step or an edge.
GetEdgeFromNode(ConstructionGraphNode, Int32)
Gets an edge from a construction node given its index.
Declaration
public ConstructionGraphEdge GetEdgeFromNode(ConstructionGraphNode node, int index)
Parameters
Type | Name | Description |
---|---|---|
ConstructionGraphNode | node | The construction node where to get the edge. |
System.Int32 | index | The index or position of the edge on the node. |
Returns
Type | Description |
---|---|
ConstructionGraphEdge | The edge on that index in the construction node, or null if none. |
GetNodeFromGraph(ConstructionGraphPrototype, String)
Gets a node from a construction graph given its identifier.
Declaration
public ConstructionGraphNode GetNodeFromGraph(ConstructionGraphPrototype graph, string id)
Parameters
Type | Name | Description |
---|---|---|
ConstructionGraphPrototype | graph | The construction graph where to get the node. |
System.String | id | The identifier that corresponds to the node. |
Returns
Type | Description |
---|---|
ConstructionGraphNode | The node that corresponds to the identifier, or null if it doesn't exist. |
GetStepFromEdge(ConstructionGraphEdge, Int32)
Gets a step from a construction edge given its index.
Declaration
public ConstructionGraphStep GetStepFromEdge(ConstructionGraphEdge edge, int index)
Parameters
Type | Name | Description |
---|---|---|
ConstructionGraphEdge | edge | The construction edge where to get the step. |
System.Int32 | index | The index or position of the step on the edge. |
Returns
Type | Description |
---|---|
ConstructionGraphStep | The edge on that index in the construction edge, or null if none. |
GetTargetEdge(EntityUid, ConstructionComponent)
Gets the construction graph edge the entity's construction pathfinding is currently targeting, if any.
Declaration
public ConstructionGraphEdge GetTargetEdge(EntityUid uid, ConstructionComponent construction)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
ConstructionGraphEdge | The construction graph edge the entity's construction pathfinding is currently targeting, or null if it's not currently targeting any edge. Also returns null if the entity does not have a ConstructionComponent. |
Remarks
Target edges are entirely optional and only used for pathfinding purposes. The targeted edge will be an edge on the current construction node the entity is at.
GetTargetNode(EntityUid, ConstructionComponent)
Gets the construction graph node the entity's construction pathfinding is currently targeting, if any.
Declaration
public ConstructionGraphNode GetTargetNode(EntityUid uid, ConstructionComponent construction)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
ConstructionGraphNode | The construction graph node the entity's construction pathfinding is currently targeting, or null if it's not currently targeting any node. Also returns null if the entity does not have a ConstructionComponent. |
Remarks
Target nodes are entirely optional and only used for pathfinding purposes.
Initialize()
Declaration
public override void Initialize()
SetPathfindingTarget(EntityUid, Nullable<String>, ConstructionComponent)
Sets or clears a pathfinding target node for a given construction entity.
Declaration
public bool SetPathfindingTarget(EntityUid uid, string? targetNodeId, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
System.Nullable<System.String> | targetNodeId | The target node to pathfind, or null to clear the current pathfinding node. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
System.Boolean | Whether we could set/clear the pathfinding target node. |
TryStartItemConstruction(String, EntityUid)
Declaration
public Task<bool> TryStartItemConstruction(string prototype, EntityUid user)
Parameters
Type | Name | Description |
---|---|---|
System.String | prototype | |
EntityUid | user |
Returns
Type | Description |
---|---|
Task<System.Boolean> |
Update(Single)
Declaration
public override void Update(float frameTime)
Parameters
Type | Name | Description |
---|---|---|
System.Single | frameTime |
UpdatePathfinding(EntityUid, ConstructionComponent)
Updates the pathfinding state for the current construction state of an entity.
Declaration
public bool UpdatePathfinding(EntityUid uid, ConstructionComponent construction = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | The target entity. |
ConstructionComponent | construction | The construction component of the target entity. Will be resolved if null. |
Returns
Type | Description |
---|---|
System.Boolean | Whether we could update the pathfinding state correctly. |