Align storage welders with door welders (#2393)
* Align storage welders with door welders * Spamming the button doesn't punish you. * Requires lit welder to start * * Nulla-builda-buddy * A certain smug in a bucket Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Interfaces.GameObjects.Components;
|
using Robust.Client.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using YamlDotNet.RepresentationModel;
|
using YamlDotNet.RepresentationModel;
|
||||||
|
|
||||||
@@ -56,9 +57,9 @@ namespace Content.Client.GameObjects.Components.Storage
|
|||||||
}
|
}
|
||||||
|
|
||||||
component.TryGetData(StorageVisuals.Open, out bool open);
|
component.TryGetData(StorageVisuals.Open, out bool open);
|
||||||
sprite.LayerSetState(StorageVisualLayers.Door, open
|
var state = open ? _stateOpen ?? $"{_stateBase}_open" : _stateClosed ?? $"{_stateBase}_door";
|
||||||
? _stateOpen ?? $"{_stateBase}_open"
|
|
||||||
: _stateClosed ?? $"{_stateBase}_door");
|
sprite.LayerSetState(StorageVisualLayers.Door, state);
|
||||||
|
|
||||||
if (component.TryGetData(StorageVisuals.CanLock, out bool canLock) && canLock)
|
if (component.TryGetData(StorageVisuals.CanLock, out bool canLock) && canLock)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using System;
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Server.GameObjects.Components.Body;
|
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.GameObjects.Components.Interactable;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Shared.GameObjects.Components.Body;
|
using Content.Shared.GameObjects.Components.Body;
|
||||||
@@ -14,7 +15,6 @@ using Content.Shared.Interfaces.GameObjects.Components;
|
|||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.Container;
|
using Robust.Server.GameObjects.Components.Container;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
@@ -47,8 +47,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private bool _isCollidableWhenOpen;
|
private bool _isCollidableWhenOpen;
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
protected IEntityQuery EntityQuery;
|
protected IEntityQuery? EntityQuery;
|
||||||
|
|
||||||
private bool _showContents;
|
private bool _showContents;
|
||||||
private bool _occludesLight;
|
private bool _occludesLight;
|
||||||
private bool _open;
|
private bool _open;
|
||||||
@@ -58,7 +57,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
private string _openSound = "/Audio/Machines/closetopen.ogg";
|
private string _openSound = "/Audio/Machines/closetopen.ogg";
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
protected Container Contents;
|
protected Container Contents = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the container contents should be drawn when the container is closed.
|
/// Determines if the container contents should be drawn when the container is closed.
|
||||||
@@ -100,20 +99,25 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
{
|
{
|
||||||
_isWeldedShut = value;
|
_isWeldedShut = value;
|
||||||
|
|
||||||
if (Owner.TryGetComponent(out AppearanceComponent appearance))
|
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(StorageVisuals.Welded, value);
|
appearance.SetData(StorageVisuals.Welded, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _beingWelded;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool CanWeldShut {
|
public bool CanWeldShut {
|
||||||
get => _canWeldShut;
|
get => _canWeldShut;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (_canWeldShut == value)
|
||||||
|
return;
|
||||||
|
|
||||||
_canWeldShut = value;
|
_canWeldShut = value;
|
||||||
if (Owner.TryGetComponent(out AppearanceComponent appearance))
|
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(StorageVisuals.CanWeld, value);
|
appearance.SetData(StorageVisuals.CanWeld, value);
|
||||||
}
|
}
|
||||||
@@ -187,6 +191,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
protected virtual void CloseStorage()
|
protected virtual void CloseStorage()
|
||||||
{
|
{
|
||||||
Open = false;
|
Open = false;
|
||||||
|
EntityQuery ??= new IntersectingEntityQuery(Owner);
|
||||||
var entities = Owner.EntityManager.GetEntities(EntityQuery);
|
var entities = Owner.EntityManager.GetEntities(EntityQuery);
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entities)
|
||||||
@@ -243,7 +248,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
placeableSurfaceComponent.IsPlaceable = Open;
|
placeableSurfaceComponent.IsPlaceable = Open;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Owner.TryGetComponent(out AppearanceComponent appearance))
|
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(StorageVisuals.Open, Open);
|
appearance.SetData(StorageVisuals.Open, Open);
|
||||||
}
|
}
|
||||||
@@ -252,7 +257,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
protected virtual bool AddToContents(IEntity entity)
|
protected virtual bool AddToContents(IEntity entity)
|
||||||
{
|
{
|
||||||
if (entity == Owner) return false;
|
if (entity == Owner) return false;
|
||||||
if (entity.TryGetComponent(out IPhysicsComponent entityPhysicsComponent))
|
if (entity.TryGetComponent(out IPhysicsComponent? entityPhysicsComponent))
|
||||||
{
|
{
|
||||||
if(MaxSize < entityPhysicsComponent.WorldAABB.Size.X
|
if(MaxSize < entityPhysicsComponent.WorldAABB.Size.X
|
||||||
|| MaxSize < entityPhysicsComponent.WorldAABB.Size.Y)
|
|| MaxSize < entityPhysicsComponent.WorldAABB.Size.Y)
|
||||||
@@ -294,7 +299,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void HandleMessage(ComponentMessage message, IComponent component)
|
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||||
{
|
{
|
||||||
base.HandleMessage(message, component);
|
base.HandleMessage(message, component);
|
||||||
|
|
||||||
@@ -367,25 +372,46 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
|
|
||||||
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
|
if (_beingWelded)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (Open)
|
if (Open)
|
||||||
|
{
|
||||||
|
_beingWelded = false;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CanWeldShut)
|
if (!CanWeldShut)
|
||||||
|
{
|
||||||
|
_beingWelded = false;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (Contents.Contains(eventArgs.User))
|
if (Contents.Contains(eventArgs.User))
|
||||||
{
|
{
|
||||||
|
_beingWelded = false;
|
||||||
Owner.PopupMessage(eventArgs.User, Loc.GetString("It's too Cramped!"));
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("It's too Cramped!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eventArgs.Using.TryGetComponent(out WelderComponent tool))
|
if (!eventArgs.Using.TryGetComponent(out WelderComponent? tool) || !tool.WelderLit)
|
||||||
|
{
|
||||||
|
_beingWelded = false;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_beingWelded)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_beingWelded = true;
|
||||||
|
|
||||||
if (!await tool.UseTool(eventArgs.User, Owner, 1f, ToolQuality.Welding, 1f))
|
if (!await tool.UseTool(eventArgs.User, Owner, 1f, ToolQuality.Welding, 1f))
|
||||||
|
{
|
||||||
|
_beingWelded = false;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_beingWelded = false;
|
||||||
IsWeldedShut ^= true;
|
IsWeldedShut ^= true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user