Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror: Fix StrippableSystem Blunders #224

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions Content.Server/Strip/StrippableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ public override void StartOpeningStripper(EntityUid user, Entity<StrippableCompo
private void OnStripButtonPressed(Entity<StrippableComponent> strippable, ref StrippingSlotButtonPressed args)
{
if (args.Session.AttachedEntity is not { Valid: true } user ||
!TryComp<HandsComponent>(user, out var userHands) ||
!TryComp<HandsComponent>(strippable.Owner, out var targetHands))
!TryComp<HandsComponent>(user, out var userHands))
return;

if (args.IsHand)
{
StripHand((user, userHands), (strippable.Owner, null), args.Slot, strippable);
return;

if (args.IsHand)
Expand Down Expand Up @@ -478,6 +482,9 @@ private void StripInsertHand(
!Resolve(target, ref target.Comp))
return;

if (!CanStripInsertHand(user, target, held, handName))
return;

_handsSystem.TryDrop(user, checkActionBlocker: false, handsComp: user.Comp);
_handsSystem.TryPickup(target, held, handName, checkActionBlocker: false, animateUser: stealth, animate: stealth, handsComp: target.Comp);
_adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):actor} has placed the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s hands");
Expand Down Expand Up @@ -536,8 +543,8 @@ private void StartStripRemoveHand(
!Resolve(target, ref targetStrippable))
return;

if (!CanStripRemoveHand(user, target, item, handName))
return;
if (!stealth)
_popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner", ("user", Identity.Entity(user, EntityManager)), ("item", item)), target, target);

var (time, stealth) = GetStripTimeModifiers(user, target, targetStrippable.HandStripDelay);

Expand Down Expand Up @@ -569,12 +576,16 @@ private void StripRemoveHand(
Entity<HandsComponent?> user,
Entity<HandsComponent?> target,
EntityUid item,
string handName,
bool stealth)
{
if (!Resolve(user, ref user.Comp) ||
!Resolve(target, ref target.Comp))
return;

if (!CanStripRemoveHand(user, target, item, handName))
return;

_handsSystem.TryDrop(target, item, checkActionBlocker: false, handsComp: target.Comp);
_handsSystem.PickupOrDrop(user, item, animateUser: stealth, animate: stealth, handsComp: user.Comp);
_adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):actor} has stripped the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s hands");
Expand All @@ -598,6 +609,12 @@ private void OnStrippableDoAfterRunning(Entity<HandsComponent> entity, ref DoAft
ev.Cancel();
}
else
{
if ( ev.Event.InsertOrRemove && !CanStripInsertInventory((entity.Owner, entity.Comp), args.Target.Value, args.Used.Value, ev.Event.SlotOrHandName) ||
!ev.Event.InsertOrRemove && !CanStripRemoveInventory(entity.Owner, args.Target.Value, args.Used.Value, ev.Event.SlotOrHandName))
ev.Cancel();
}
else
{
if ( ev.Event.InsertOrRemove && !CanStripInsertHand((entity.Owner, entity.Comp), args.Target.Value, args.Used.Value, ev.Event.SlotOrHandName) ||
!ev.Event.InsertOrRemove && !CanStripRemoveHand(entity.Owner, args.Target.Value, args.Used.Value, ev.Event.SlotOrHandName))
Expand Down Expand Up @@ -625,7 +642,7 @@ private void OnStrippableDoAfterFinished(Entity<HandsComponent> entity, ref Stri
{
if (ev.InsertOrRemove)
StripInsertHand((entity.Owner, entity.Comp), ev.Target.Value, ev.Used.Value, ev.SlotOrHandName, ev.Args.Hidden);
else StripRemoveHand((entity.Owner, entity.Comp), ev.Target.Value, ev.Used.Value, ev.Args.Hidden);
else StripRemoveHand((entity.Owner, entity.Comp), ev.Target.Value, ev.Used.Value, ev.SlotOrHandName, ev.Args.Hidden);
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions Content.Shared/Strip/Components/StrippableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
}

[NetSerializable, Serializable]
public sealed class StrippingEnsnareButtonPressed : BoundUserInterfaceMessage;

[ByRefEvent]
public abstract class BaseBeforeStripEvent(TimeSpan initialTime, bool stealth = false) : EntityEventArgs, IInventoryRelayEvent
public sealed class StrippingEnsnareButtonPressed : BoundUserInterfaceMessage
{
public readonly TimeSpan InitialTime = initialTime;
public TimeSpan Multiplier = TimeSpan.FromSeconds(1f);
public float Multiplier = 1f;
public TimeSpan Additive = TimeSpan.Zero;
public bool Stealth = stealth;

public TimeSpan Time => TimeSpan.FromSeconds(MathF.Max(InitialTime.Seconds * Multiplier + Additive.Seconds, 0f));

public TimeSpan Time => TimeSpan.FromSeconds(MathF.Max(InitialTime.Seconds * Multiplier.Seconds + Additive.Seconds, 0f));

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

Check failure on line 41 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type 'StrippingEnsnareButtonPressed' already contains a definition for 'Time'

public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES;
}
Expand All @@ -51,7 +50,7 @@
/// This is also used by some stripping related interactions, i.e., interactions with items that are currently equipped by another player.
/// </remarks>
[ByRefEvent]
public sealed class BeforeStripEvent(TimeSpan initialTime, bool stealth = false) : BaseBeforeStripEvent(initialTime, stealth);

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

/// <summary>
/// Used to modify strip times. Raised directed at the target.
Expand All @@ -60,7 +59,7 @@
/// This is also used by some stripping related interactions, i.e., interactions with items that are currently equipped by another player.
/// </remarks>
[ByRefEvent]
public sealed class BeforeGettingStrippedEvent(TimeSpan initialTime, bool stealth = false) : BaseBeforeStripEvent(initialTime, stealth);

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 62 in Content.Shared/Strip/Components/StrippableComponent.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'BaseBeforeStripEvent' could not be found (are you missing a using directive or an assembly reference?)

/// <summary>
/// Organizes the behavior of DoAfters for <see cref="StrippableSystem">.
Expand Down
Loading