Skip to content

Commit

Permalink
make changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WarMechanic committed Jul 1, 2024
1 parent 7c83c8b commit c35bf9e
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 41 deletions.
5 changes: 4 additions & 1 deletion Content.Client/Inventory/StrippableBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.Player;
using Robust.Shared.Input;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
Expand All @@ -31,6 +32,7 @@ namespace Content.Client.Inventory
public sealed class StrippableBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IUserInterfaceManager _ui = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly ExamineSystem _examine;
private readonly InventorySystem _inv;
private readonly SharedCuffableSystem _cuffable;
Expand Down Expand Up @@ -198,7 +200,8 @@ private void AddInventoryButton(EntityUid invUid, string slotId, InventoryCompon
var entity = container.ContainedEntity;

// If this is a full pocket, obscure the real entity
if (entity != null && slotDef.StripHidden)
if (entity != null && slotDef.StripHidden
&& !(EntMan.TryGetComponent<ThievingComponent>(_playerManager.LocalEntity, out var thiefcomponent) && thiefcomponent.IgnoreStripHidden))
entity = _virtualHiddenEntity;

var button = new SlotButton(new SlotData(slotDef, container));
Expand Down
70 changes: 44 additions & 26 deletions Content.Server/Strip/StrippableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ bool Check()
var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth);
RaiseLocalEvent(target, ev);

bool hidden = ev.Stealth == ThievingStealth.Hidden;

var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held)
{
ExtraCheck = Check,
Hidden = ev.Stealth,
Hidden = hidden,
AttemptFrequency = AttemptFrequency.EveryTick,
BreakOnDamage = true,
BreakOnTargetMove = true,
Expand All @@ -231,14 +233,18 @@ bool Check()
DuplicateCondition = DuplicateConditions.SameTool // Block any other DoAfters featuring this same entity.
};

if (!ev.Stealth && Check() && userHands.ActiveHandEntity != null)
if (!hidden && Check() && userHands.ActiveHandEntity != null)
{
var message = Loc.GetString("strippable-component-alert-owner-insert",
("user", Identity.Entity(user, EntityManager)), ("item", userHands.ActiveHandEntity));
_popup.PopupEntity(message, target, target, PopupType.Large);
bool subtle = (ev.Stealth == ThievingStealth.Subtle);
PopupType popupSize = subtle ? PopupType.Small : PopupType.Large;

_popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-insert",
("user", subtle ? "Someone" : Identity.Entity(user, EntityManager)),
("item", subtle ? "something" : userHands.ActiveHandEntity)),
target, target, popupSize);
}

var prefix = ev.Stealth ? "stealthily " : "";
var prefix = hidden ? "stealthily " : "";
_adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}place the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s {slot} slot");

var result = await _doAfter.WaitDoAfter(doAfterArgs);
Expand Down Expand Up @@ -294,10 +300,12 @@ bool Check()
var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth);
RaiseLocalEvent(target, ev);

bool hidden = (ev.Stealth == ThievingStealth.Hidden);

var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held)
{
ExtraCheck = Check,
Hidden = ev.Stealth,
Hidden = hidden,
AttemptFrequency = AttemptFrequency.EveryTick,
BreakOnDamage = true,
BreakOnTargetMove = true,
Expand All @@ -306,14 +314,14 @@ bool Check()
DuplicateCondition = DuplicateConditions.SameTool
};

var prefix = ev.Stealth ? "stealthily " : "";
var prefix = hidden ? "stealthily " : "";
_adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}place the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s hands");

var result = await _doAfter.WaitDoAfter(doAfterArgs);
if (result != DoAfterStatus.Finished) return;

_handsSystem.TryDrop(user, checkActionBlocker: false, handsComp: userHands);
_handsSystem.TryPickup(target, held, handName, checkActionBlocker: false, animateUser: !ev.Stealth, animate: !ev.Stealth, handsComp: hands);
_handsSystem.TryPickup(target, held, handName, checkActionBlocker: false, animateUser: !hidden, animate: !hidden, handsComp: hands);
_adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):actor} has placed the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s hands");
// hand update will trigger strippable update
}
Expand Down Expand Up @@ -356,10 +364,12 @@ bool Check()
var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth);
RaiseLocalEvent(target, ev);

bool hidden = (ev.Stealth == ThievingStealth.Hidden);

var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item)
{
ExtraCheck = Check,
Hidden = ev.Stealth,
Hidden = hidden,
AttemptFrequency = AttemptFrequency.EveryTick,
BreakOnDamage = true,
BreakOnTargetMove = true,
Expand All @@ -369,21 +379,26 @@ bool Check()
DuplicateCondition = DuplicateConditions.SameTool
};

if (!ev.Stealth && Check())
if (!hidden && Check())
{
PopupType popupSize = (ev.Stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large;

if (slotDef.StripHidden)
{
_popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", ("slot", slot)), target,
target, PopupType.Large);
_popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden",
("slot", slot)),
target, target, popupSize);
}
else if (_inventorySystem.TryGetSlotEntity(strippable, slot, out var slotItem))
{
_popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", ("user", Identity.Entity(user, EntityManager)), ("item", slotItem)), target,
target, PopupType.Large);
_popup.PopupEntity(Loc.GetString("strippable-component-alert-owner",
("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)),
("item", slotItem)),
target, target, popupSize);
}
}

var prefix = ev.Stealth ? "stealthily " : "";
var prefix = hidden ? "stealthily " : "";
_adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}strip the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s {slot} slot");

var result = await _doAfter.WaitDoAfter(doAfterArgs);
Expand All @@ -396,7 +411,7 @@ bool Check()
// Raise a dropped event, so that things like gas tank internals properly deactivate when stripping
RaiseLocalEvent(item, new DroppedEvent(user), true);

_handsSystem.PickupOrDrop(user, item, animateUser: !ev.Stealth, animate: !ev.Stealth);
_handsSystem.PickupOrDrop(user, item, animateUser: !hidden, animate: !hidden);
_adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):actor} has stripped the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s {slot} slot");

}
Expand Down Expand Up @@ -434,10 +449,12 @@ bool Check()
var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth);
RaiseLocalEvent(target, ev);

bool hidden = (ev.Stealth == ThievingStealth.Hidden);

var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item)
{
ExtraCheck = Check,
Hidden = ev.Stealth,
Hidden = hidden,
AttemptFrequency = AttemptFrequency.EveryTick,
BreakOnDamage = true,
BreakOnTargetMove = true,
Expand All @@ -447,16 +464,17 @@ bool Check()
DuplicateCondition = DuplicateConditions.SameTool
};

if (!ev.Stealth && Check() && _handsSystem.TryGetHand(target, handName, out var handSlot, hands) && handSlot.HeldEntity != null)
if (!hidden && Check() && _handsSystem.TryGetHand(target, handName, out var handSlot, hands) && handSlot.HeldEntity != null)
{
_popup.PopupEntity(
Loc.GetString("strippable-component-alert-owner",
("user", Identity.Entity(user, EntityManager)), ("item", item)),
strippable.Owner,
strippable.Owner);
PopupType popupSize = (ev.Stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large;

_popup.PopupEntity(Loc.GetString("strippable-component-alert-owner",
("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)),
("item", item)),
strippable.Owner,strippable.Owner, popupSize);
}

var prefix = ev.Stealth ? "stealthily " : "";
var prefix = hidden ? "stealthily " : "";
_adminLogger.Add(LogType.Stripping, LogImpact.Low,
$"{ToPrettyString(user):actor} is trying to {prefix}strip the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s hands");

Expand All @@ -465,7 +483,7 @@ bool Check()
return;

_handsSystem.TryDrop(target, item, checkActionBlocker: false, handsComp: hands);
_handsSystem.PickupOrDrop(user, item, animateUser: !ev.Stealth, animate: !ev.Stealth, handsComp: userHands);
_handsSystem.PickupOrDrop(user, item, animateUser: !hidden, animate: !hidden, handsComp: userHands);
// hand update will trigger strippable update
_adminLogger.Add(LogType.Stripping, LogImpact.Medium,
$"{ToPrettyString(user):actor} has stripped the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s hands");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ private void StartDoAfter(EntityUid user, EntityUid item, EntityUid wearer, Togg

var (time, stealth) = _strippable.GetStripTimeModifiers(user, wearer, (float) component.StripDelay.Value.TotalSeconds);

bool hidden = (stealth == ThievingStealth.Hidden);

var args = new DoAfterArgs(EntityManager, user, time, new ToggleClothingDoAfterEvent(), item, wearer, item)
{
BreakOnDamage = true,
Expand All @@ -110,10 +112,14 @@ private void StartDoAfter(EntityUid user, EntityUid item, EntityUid wearer, Togg
if (!_doAfter.TryStartDoAfter(args))
return;

if (!stealth)
if (!hidden)
{
var popup = Loc.GetString("strippable-component-alert-owner-interact", ("user", Identity.Entity(user, EntityManager)), ("item", item));
_popupSystem.PopupEntity(popup, wearer, wearer, PopupType.Large);
PopupType popupSize = (stealth == ThievingStealth.Subtle);

_popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner-interact",
("user", (stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)),
("item", item)),
wearer, wearer, popupSize);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Content.Shared/Strip/Components/StrippableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public abstract class BaseBeforeStripEvent : EntityEventArgs, IInventoryRelayEve
public float Time => MathF.Max(InitialTime * Multiplier + Additive, 0f);
public float Additive = 0;
public float Multiplier = 1f;
public bool Stealth;
public ThievingStealth Stealth;

public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES;

public BaseBeforeStripEvent(float initialTime, bool stealth = false)
public BaseBeforeStripEvent(float initialTime, ThievingStealth stealth = ThievingStealth.Obvious)
{
InitialTime = initialTime;
Stealth = stealth;
Expand All @@ -67,7 +67,7 @@ public BaseBeforeStripEvent(float initialTime, bool stealth = false)
/// </remarks>
public sealed class BeforeStripEvent : BaseBeforeStripEvent
{
public BeforeStripEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { }
public BeforeStripEvent(float initialTime, ThievingStealth stealth = ThievingStealth.Obvious) : base(initialTime, stealth) { }
}

/// <summary>
Expand All @@ -78,6 +78,6 @@ public BeforeStripEvent(float initialTime, bool stealth = false) : base(initialT
/// </remarks>
public sealed class BeforeGettingStrippedEvent : BaseBeforeStripEvent
{
public BeforeGettingStrippedEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { }
public BeforeGettingStrippedEvent(float initialTime, ThievingStealth stealth = ThievingStealth.Obvious) : base(initialTime, stealth) { }
}
}
20 changes: 15 additions & 5 deletions Content.Shared/Strip/Components/ThievingComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@ public sealed partial class ThievingComponent : Component
/// <summary>
/// How much the strip time should be shortened by
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("stripTimeReduction")]
[DataField]
public float StripTimeReduction = 0.5f;

/// <summary>
/// A multiplier coefficient for strip time
/// </summary>
[DataField]
public float StripTimeMultiplier = 1f;

/// <summary>
/// Should it notify the user if they're stripping a pocket?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("stealthy")]
public bool Stealthy;
[DataField]
public ThievingStealth Stealth = ThievingStealth.Hidden;

/// <summary>
/// Should the user be able to see hidden items? (i.e pockets)
/// </summary>
[DataField]
public bool IgnoreStripHidden;
}
2 changes: 1 addition & 1 deletion Content.Shared/Strip/SharedStrippableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public override void Initialize()
SubscribeLocalEvent<StrippableComponent, DragDropDraggedEvent>(OnDragDrop);
}

public (float Time, bool Stealth) GetStripTimeModifiers(EntityUid user, EntityUid target, float initialTime)
public (float Time, ThievingStealth Stealth) GetStripTimeModifiers(EntityUid user, EntityUid target, float initialTime)
{
var userEv = new BeforeStripEvent(initialTime);
RaiseLocalEvent(user, userEv);
Expand Down
22 changes: 21 additions & 1 deletion Content.Shared/Strip/ThievingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Inventory;
using Content.Shared.Strip.Components;
using Robust.Shared.Serialization;

namespace Content.Shared.Strip;

Expand All @@ -16,7 +17,26 @@ public override void Initialize()

private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStripEvent args)
{
args.Stealth |= component.Stealthy;
args.Stealth = (ThievingStealth) Math.Max(((sbyte) args.Stealth), (sbyte) component.Stealth);
args.Additive -= component.StripTimeReduction;
args.Multiplier *= component.StripTimeMultiplier;
}
}
[Serializable, NetSerializable]
public enum ThievingStealth : sbyte
{
/// <summary>
/// Target sees a large popup indicating that an item is being stolen by who
/// </summary>
Obvious = 0,

/// <summary>
/// Target sees a small popup indicating that an item is being stolen
/// </summary>
Subtle = 1,

/// <summary>
/// Target does not see any popup regarding the stealing of an item
/// </summary>
Hidden = 2
}
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ trait-description-SocialAnxiety = You are anxious when you speak and stutter.
trait-name-Snoring = Snoring
trait-description-Snoring = You will snore while sleeping.
trait-name-Thieving = Thieving
trait-description-Thieving = You are deft with your hands, and talented at convincing people of their belongings.
Your attempts at stealing items are quieter, and you steal ~33% faster.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
- GalacticCommon
- SolCommon
- Nekomimetic
- type: Thieving
ignoreStripHidden: true
stealth: Subtle
stripTimeReduction: 0
stripTimeMultiplier: 0.667

- type: entity
save: false
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/Traits/skills.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- type: trait
id: Thieving
category: Uncategorized
points: -4
components:
- type: Thieving
ignoreStripHidden: true
stealth: Subtle
stripTimeReduction: 0
stripTimeMultiplier: 0.667
requirements:
- !type:CharacterSpeciesRequirement
inverted: true
species: Felinid

0 comments on commit c35bf9e

Please sign in to comment.