Re-organize all projects (#4166)
This commit is contained in:
61
Content.Server/Rotation/Components/FlippableComponent.cs
Normal file
61
Content.Server/Rotation/Components/FlippableComponent.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
#nullable enable
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Notification;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Rotation.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class FlippableComponent : Component
|
||||
{
|
||||
public override string Name => "Flippable";
|
||||
|
||||
|
||||
private string? _entity => _internalEntity ?? Owner.Prototype?.ID;
|
||||
|
||||
[DataField("entity")]
|
||||
private string? _internalEntity;
|
||||
|
||||
private void TryFlip(IEntity user)
|
||||
{
|
||||
if (Owner.TryGetComponent(out IPhysBody? physics) &&
|
||||
physics.BodyType == BodyType.Static)
|
||||
{
|
||||
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_entity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Owner.EntityManager.SpawnEntity(_entity, Owner.Transform.Coordinates);
|
||||
Owner.Delete();
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user