Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
|
using Content.Server.Utility;
|
|
using Content.Shared.GameObjects.Components;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Server.GameObjects.Components
|
|
{
|
|
[RegisterComponent]
|
|
public class PlaceableSurfaceComponent : SharedPlaceableSurfaceComponent, IInteractUsing
|
|
{
|
|
private bool _isPlaceable;
|
|
public bool IsPlaceable { get => _isPlaceable; set => _isPlaceable = value; }
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
|
|
serializer.DataField(ref _isPlaceable, "IsPlaceable", true);
|
|
}
|
|
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
|
{
|
|
if (!IsPlaceable)
|
|
return false;
|
|
|
|
if(!eventArgs.User.TryGetComponent<HandsComponent>(out var handComponent))
|
|
{
|
|
return false;
|
|
}
|
|
handComponent.Drop(eventArgs.Using);
|
|
eventArgs.Using.Transform.WorldPosition = eventArgs.ClickLocation.Position;
|
|
return true;
|
|
}
|
|
}
|
|
}
|