From 1ab8d3e6e9f7bb00d15c5555a2dbb908f96f195e Mon Sep 17 00:00:00 2001 From: mirrorcult Date: Tue, 16 Feb 2021 01:42:03 -0700 Subject: [PATCH] Properly fix chair collision & disallow pulling objects you're buckled to (#3241) Co-authored-by: cyclowns --- .../Components/Buckle/BuckleComponent.cs | 7 ++- .../Components/Buckle/BuckleComponent.cs | 15 ++++- .../Constructible/Furniture/seats.yml | 61 +++++++++++-------- 3 files changed, 52 insertions(+), 31 deletions(-) diff --git a/Content.Client/GameObjects/Components/Buckle/BuckleComponent.cs b/Content.Client/GameObjects/Components/Buckle/BuckleComponent.cs index 1426d13ae7..3c2e949562 100644 --- a/Content.Client/GameObjects/Components/Buckle/BuckleComponent.cs +++ b/Content.Client/GameObjects/Components/Buckle/BuckleComponent.cs @@ -1,4 +1,5 @@ -using Content.Shared.GameObjects.Components.Buckle; +#nullable enable +using Content.Shared.GameObjects.Components.Buckle; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; @@ -19,7 +20,7 @@ namespace Content.Client.GameObjects.Components.Buckle return false; } - public override void HandleComponentState(ComponentState curState, ComponentState nextState) + public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) { if (curState is not BuckleComponentState buckle) { @@ -30,7 +31,7 @@ namespace Content.Client.GameObjects.Components.Buckle LastEntityBuckledTo = buckle.LastEntityBuckledTo; DontCollide = buckle.DontCollide; - if (!Owner.TryGetComponent(out SpriteComponent ownerSprite)) + if (!Owner.TryGetComponent(out SpriteComponent? ownerSprite)) { return; } diff --git a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs index 390abb301c..3dd0e534f4 100644 --- a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs @@ -263,11 +263,20 @@ namespace Content.Server.GameObjects.Components.Buckle SendMessage(new BuckleMessage(Owner, to)); - if (Owner.TryGetComponent(out PullableComponent? pullableComponent)) + if (Owner.TryGetComponent(out PullableComponent? ownerPullable)) { - if (pullableComponent.Puller != null) + if (ownerPullable.Puller != null) { - pullableComponent.TryStopPull(); + ownerPullable.TryStopPull(); + } + } + + if (to.TryGetComponent(out PullableComponent? toPullable)) + { + if (toPullable.Puller == Owner) + { + // can't pull it and buckle to it at the same time + toPullable.TryStopPull(); } } diff --git a/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml b/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml index 512a3f2e0d..f9f4a0bf2d 100644 --- a/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml +++ b/Resources/Prototypes/Entities/Constructible/Furniture/seats.yml @@ -15,13 +15,6 @@ bounds: "-0.5,-0.25,0.5,0.25" mask: - Impassable - - MobImpassable - - VaultImpassable - - SmallImpassable - layer: - - Opaque - - Impassable - - MobImpassable - VaultImpassable - SmallImpassable - type: Sprite @@ -52,9 +45,12 @@ color: "#8e9799" - type: Physics shapes: - - !type:PhysShapeAabb - bounds: "-0.45, -0.45, 0.05, 0.45" - layer: [ Passable ] + - !type:PhysShapeAabb + bounds: "-0.45, -0.45, 0.05, 0.45" + mask: + - Impassable + - VaultImpassable + - SmallImpassable - type: entity name: stool @@ -67,9 +63,12 @@ color: "#8e9799" - type: Physics shapes: - - !type:PhysShapeAabb - bounds: "-0.5, -0.25, 0.05, 0.25" - layer: [ Passable ] + - !type:PhysShapeAabb + bounds: "-0.5, -0.25, 0.05, 0.25" + mask: + - Impassable + - VaultImpassable + - SmallImpassable - type: entity name: bar stool @@ -81,9 +80,12 @@ color: "white" - type: Physics shapes: - - !type:PhysShapeAabb - bounds: "-0.5, -0.2, 0.2, 0.25" - layer: [ Passable ] + - !type:PhysShapeAabb + bounds: "-0.5, -0.2, 0.2, 0.25" + mask: + - Impassable + - VaultImpassable + - SmallImpassable - type: entity name: white office chair @@ -96,9 +98,12 @@ state: officechair_white - type: Physics shapes: - - !type:PhysShapeAabb - bounds: "-0.49, -0.25, 0.37, 0.25" - layer: [ Passable ] + - !type:PhysShapeAabb + bounds: "-0.49, -0.25, 0.37, 0.25" + mask: + - Impassable + - VaultImpassable + - SmallImpassable - type: entity name: dark office chair @@ -118,9 +123,12 @@ state: comfychair_preview - type: Physics shapes: - - !type:PhysShapeAabb - bounds: "-0.45, -0.3, 0.35, 0.3" - layer: [ Passable ] + - !type:PhysShapeAabb + bounds: "-0.45, -0.3, 0.35, 0.3" + mask: + - Impassable + - VaultImpassable + - SmallImpassable - type: entity name: wooden chair @@ -132,6 +140,9 @@ color: "white" - type: Physics shapes: - - !type:PhysShapeAabb - bounds: "-0.37, -0.25, 0.49, 0.24" - layer: [ Passable ] + - !type:PhysShapeAabb + bounds: "-0.37, -0.25, 0.49, 0.24" + mask: + - Impassable + - VaultImpassable + - SmallImpassable