Fix rsi sprite access for verbs (#14284)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Rotatable;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Rotatable
|
||||
{
|
||||
@@ -11,6 +13,8 @@ namespace Content.Server.Rotatable
|
||||
/// </summary>
|
||||
public sealed class RotatableSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<FlippableComponent, GetVerbsEvent<Verb>>(AddFlipVerb);
|
||||
@@ -19,13 +23,15 @@ namespace Content.Server.Rotatable
|
||||
|
||||
private void AddFlipVerb(EntityUid uid, FlippableComponent component, GetVerbsEvent<Verb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || component.MirrorEntity == null)
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
return;
|
||||
|
||||
Verb verb = new();
|
||||
verb.Act = () => TryFlip(component, args.User);
|
||||
verb.Text = Loc.GetString("flippable-verb-get-data-text");
|
||||
verb.DoContactInteraction = true;
|
||||
Verb verb = new()
|
||||
{
|
||||
Act = () => TryFlip(uid, component, args.User),
|
||||
Text = Loc.GetString("flippable-verb-get-data-text"),
|
||||
DoContactInteraction = true
|
||||
};
|
||||
// TODO VERB ICONS Add Uno reverse card style icon?
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
@@ -39,16 +45,16 @@ namespace Content.Server.Rotatable
|
||||
|
||||
// Check if the object is anchored, and whether we are still allowed to rotate it.
|
||||
if (!component.RotateWhileAnchored &&
|
||||
EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physics) &&
|
||||
EntityManager.TryGetComponent(uid, out PhysicsComponent? physics) &&
|
||||
physics.BodyType == BodyType.Static)
|
||||
return;
|
||||
|
||||
Verb resetRotation = new ()
|
||||
{
|
||||
DoContactInteraction = true,
|
||||
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation = Angle.Zero,
|
||||
Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation = Angle.Zero,
|
||||
Category = VerbCategory.Rotate,
|
||||
IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png",
|
||||
Icon = new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/refresh.svg.192dpi.png")),
|
||||
Text = "Reset",
|
||||
Priority = -2, // show CCW, then CW, then reset
|
||||
CloseMenu = false,
|
||||
@@ -58,9 +64,9 @@ namespace Content.Server.Rotatable
|
||||
// rotate clockwise
|
||||
Verb rotateCW = new()
|
||||
{
|
||||
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation -= component.Increment,
|
||||
Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation -= component.Increment,
|
||||
Category = VerbCategory.Rotate,
|
||||
IconTexture = "/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png",
|
||||
Icon = new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png")),
|
||||
Priority = -1,
|
||||
CloseMenu = false, // allow for easy double rotations.
|
||||
};
|
||||
@@ -69,9 +75,9 @@ namespace Content.Server.Rotatable
|
||||
// rotate counter-clockwise
|
||||
Verb rotateCCW = new()
|
||||
{
|
||||
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation += component.Increment,
|
||||
Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation += component.Increment,
|
||||
Category = VerbCategory.Rotate,
|
||||
IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png",
|
||||
Icon = new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png")),
|
||||
Priority = 0,
|
||||
CloseMenu = false, // allow for easy double rotations.
|
||||
};
|
||||
@@ -81,21 +87,21 @@ namespace Content.Server.Rotatable
|
||||
/// <summary>
|
||||
/// Replace a flippable entity with it's flipped / mirror-symmetric entity.
|
||||
/// </summary>
|
||||
public void TryFlip(FlippableComponent component, EntityUid user)
|
||||
public void TryFlip(EntityUid uid, FlippableComponent component, EntityUid user)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physics) &&
|
||||
if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physics) &&
|
||||
physics.BodyType == BodyType.Static)
|
||||
{
|
||||
component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck"));
|
||||
_popup.PopupEntity(Loc.GetString("flippable-component-try-flip-is-stuck"), uid, user);
|
||||
return;
|
||||
}
|
||||
|
||||
var oldTransform = EntityManager.GetComponent<TransformComponent>(component.Owner);
|
||||
var oldTransform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||
var entity = EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates);
|
||||
var newTransform = EntityManager.GetComponent<TransformComponent>(entity);
|
||||
newTransform.LocalRotation = oldTransform.LocalRotation;
|
||||
newTransform.Anchored = false;
|
||||
EntityManager.DeleteEntity(component.Owner);
|
||||
EntityManager.DeleteEntity(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user