From 5cac4c59171085531962ca991cd944aaa7d9947d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Wed, 4 Nov 2020 11:21:01 +0100 Subject: [PATCH] RotatableComponent QOL improvements. - Rotatable verbs only show if the entity can be rotated. - Adds parameter to rotate anchored entities. - Office chairs can now be rotated regardless of anchoring. --- .../Rotatable/RotatableComponent.cs | 20 ++++++++++++++++--- .../Constructible/Furniture/seats.yml | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs b/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs index 142cf392e2..403b7d73fd 100644 --- a/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs +++ b/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs @@ -6,6 +6,8 @@ using Robust.Shared.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Maths; +using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components.Rotatable { @@ -14,9 +16,21 @@ namespace Content.Server.GameObjects.Components.Rotatable { public override string Name => "Rotatable"; + /// + /// If true, this entity can be rotated even while anchored. + /// + [ViewVariables(VVAccess.ReadWrite)] + public bool RotateWhileAnchored { get; private set; } + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + serializer.DataField(this, x => x.RotateWhileAnchored, "rotateWhileAnchored", false); + } + private void TryRotate(IEntity user, Angle angle) { - if (Owner.TryGetComponent(out IPhysicsComponent physics)) + if (!RotateWhileAnchored && Owner.TryGetComponent(out IPhysicsComponent physics)) { if (physics.Anchored) { @@ -33,7 +47,7 @@ namespace Content.Server.GameObjects.Components.Rotatable { protected override void GetData(IEntity user, RotatableComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysicsComponent physics) && physics.Anchored)) { data.Visibility = VerbVisibility.Invisible; return; @@ -55,7 +69,7 @@ namespace Content.Server.GameObjects.Components.Rotatable { protected override void GetData(IEntity user, RotatableComponent component, VerbData data) { - if (!ActionBlockerSystem.CanInteract(user)) + if (!ActionBlockerSystem.CanInteract(user) || (!component.RotateWhileAnchored && component.Owner.TryGetComponent(out IPhysicsComponent physics) && physics.Anchored)) { data.Visibility = VerbVisibility.Invisible; return; diff --git a/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml b/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml index d66cf66bd4..5179d2cce2 100644 --- a/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml +++ b/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml @@ -83,6 +83,7 @@ parent: SeatBase components: - type: Rotatable + rotateWhileAnchored: true - type: Sprite state: officechair_white - type: Physics