The construction system can now prevent recipes from being rotated.

This commit is contained in:
Víctor Aguilera Puerto
2020-10-12 14:22:31 +02:00
parent 0f709225c3
commit c023f26a1c
4 changed files with 18 additions and 2 deletions

View File

@@ -8,15 +8,18 @@ using Robust.Shared.Map;
namespace Content.Client.Construction
{
public class ConstructionPlacementHijack : PlacementHijack
public sealed class ConstructionPlacementHijack : PlacementHijack
{
private readonly ConstructionSystem _constructionSystem;
private readonly ConstructionPrototype _prototype;
public override bool CanRotate { get; }
public ConstructionPlacementHijack(ConstructionSystem constructionSystem, ConstructionPrototype prototype)
{
_constructionSystem = constructionSystem;
_prototype = prototype;
CanRotate = prototype.CanRotate;
}
/// <inheritdoc />

View File

@@ -448,7 +448,7 @@ namespace Content.Server.GameObjects.EntitySystems
}
structure.Transform.Coordinates = ev.Location;
structure.Transform.LocalRotation = ev.Angle;
structure.Transform.LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.South;
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack));

View File

@@ -54,6 +54,11 @@ namespace Content.Shared.Construction
public string PlacementMode { get; private set; }
/// <summary>
/// Whether this construction can be constructed rotated or not.
/// </summary>
public bool CanRotate { get; private set; }
public IReadOnlyList<IConstructionCondition> Conditions => _conditions;
public void LoadFrom(YamlMappingNode mapping)
@@ -71,6 +76,7 @@ namespace Content.Shared.Construction
ser.DataField(this, x => x.PlacementMode, "placementMode", "PlaceFree");
ser.DataField(this, x => x.CanBuildInImpassable, "canBuildInImpassable", false);
ser.DataField(this, x => x.Category, "category", string.Empty);
ser.DataField(this, x => x.CanRotate, "canRotate", true);
ser.DataField(ref _conditions, "conditions", new List<IConstructionCondition>());
}
}

View File

@@ -11,6 +11,7 @@
state: wall_girder
objectType: Structure
placementMode: SnapgridCenter
canRotate: false
- type: construction
name: wall
@@ -25,6 +26,7 @@
state: full
objectType: Structure
placementMode: SnapgridCenter
canRotate: false
- type: construction
name: reinforced wall
@@ -39,6 +41,7 @@
state: rgeneric
objectType: Structure
placementMode: SnapgridCenter
canRotate: false
- type: construction
name: low wall
@@ -55,6 +58,7 @@
state: metal
objectType: Structure
placementMode: SnapgridCenter
canRotate: false
- type: construction
name: window
@@ -71,6 +75,7 @@
state: full
objectType: Structure
placementMode: SnapgridCenter
canRotate: false
- type: construction
name: reinforced window
@@ -87,6 +92,7 @@
state: full
objectType: Structure
placementMode: SnapgridCenter
canRotate: false
- type: construction
name: phoron window
@@ -103,3 +109,4 @@
state: full
objectType: Structure
placementMode: SnapgridCenter
canRotate: false