* Update RobustToolbox * Transition direct type usages * More updates * Fix invalid use of to map * Update RobustToolbox * Fix dropping items * Rename name usages of "GridCoordinates" to "EntityCoordinates" * Revert "Update RobustToolbox" This reverts commit 9f334a17c5908ded0043a63158bb671e4aa3f346. * Revert "Update RobustToolbox" This reverts commit 3a9c8cfa3606fa501aa84407796d2ad920853a09. # Conflicts: # RobustToolbox * Fix cursed IMapGrid method usage. * GridTileLookupTest now uses EntityCoordinates Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <zddm@outlook.es>
66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
#nullable enable
|
|
using Content.Shared.GameObjects.EntitySystems;
|
|
using Content.Shared.GameObjects.Verbs;
|
|
using Content.Shared.Interfaces;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Components;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.Localization;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Server.GameObjects.Components.Rotatable
|
|
{
|
|
[RegisterComponent]
|
|
public class FlippableComponent : Component
|
|
{
|
|
public override string Name => "Flippable";
|
|
|
|
private string? _entity;
|
|
|
|
private void TryFlip(IEntity user)
|
|
{
|
|
if (Owner.TryGetComponent(out ICollidableComponent? collidable) &&
|
|
collidable.Anchored)
|
|
{
|
|
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
|
|
return;
|
|
}
|
|
|
|
if (_entity == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Owner.EntityManager.SpawnEntity(_entity, Owner.Transform.Coordinates);
|
|
Owner.Delete();
|
|
}
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
|
|
serializer.DataField(ref _entity, "entity", Owner.Prototype?.ID);
|
|
}
|
|
|
|
[Verb]
|
|
private sealed class FlippableVerb : Verb<FlippableComponent>
|
|
{
|
|
protected override void GetData(IEntity user, FlippableComponent component, VerbData data)
|
|
{
|
|
if (!ActionBlockerSystem.CanInteract(user))
|
|
{
|
|
data.Visibility = VerbVisibility.Invisible;
|
|
return;
|
|
}
|
|
|
|
data.Text = Loc.GetString("Flip");
|
|
}
|
|
|
|
protected override void Activate(IEntity user, FlippableComponent component)
|
|
{
|
|
component.TryFlip(user);
|
|
}
|
|
}
|
|
}
|
|
}
|