Hugging yourself no longer allowed (#8103)

!1984.

I want to hug the other person damnit.
This commit is contained in:
metalgearsloth
2022-05-12 12:56:02 +10:00
committed by GitHub
parent 12b7bf78b7
commit e6aeaa2f2f
2 changed files with 55 additions and 56 deletions

View File

@@ -3,65 +3,64 @@ using Content.Shared.Sound;
namespace Content.Server.Interaction.Components; namespace Content.Server.Interaction.Components;
[RegisterComponent, Friend(typeof(InteractionPopupSystem))] [RegisterComponent, Friend(typeof(InteractionPopupSystem))]
public sealed class InteractionPopupComponent : Component
{
/// <summary>
/// Time delay between interactions to avoid spam.
/// </summary>
[DataField("interactDelay")]
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan InteractDelay = TimeSpan.FromSeconds(1.0);
public sealed class InteractionPopupComponent : Component /// <summary>
{ /// String will be used to fetch the localized message to be played if the interaction succeeds.
/// <summary> /// Nullable in case none is specified on the yaml prototype.
/// Time delay between interactions to avoid spam. /// </summary>
/// </summary> [DataField("interactSuccessString")]
[DataField("interactDelay")] public string? InteractSuccessString;
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan InteractDelay = TimeSpan.FromSeconds(1.0);
/// <summary> /// <summary>
/// String will be used to fetch the localized message to be played if the interaction succeeds. /// String will be used to fetch the localized message to be played if the interaction fails.
/// Nullable in case none is specified on the yaml prototype. /// Nullable in case no message is specified on the yaml prototype.
/// </summary> /// </summary>
[DataField("interactSuccessString")] [DataField("interactFailureString")]
public string? InteractSuccessString; public string? InteractFailureString;
/// <summary> /// <summary>
/// String will be used to fetch the localized message to be played if the interaction fails. /// Sound effect to be played when the interaction succeeds.
/// Nullable in case no message is specified on the yaml prototype. /// Nullable in case no path is specified on the yaml prototype.
/// </summary> /// </summary>
[DataField("interactFailureString")] [DataField("interactSuccessSound")]
public string? InteractFailureString; public SoundSpecifier? InteractSuccessSound;
/// <summary> /// <summary>
/// Sound effect to be played when the interaction succeeds. /// Sound effect to be played when the interaction fails.
/// Nullable in case no path is specified on the yaml prototype. /// Nullable in case no path is specified on the yaml prototype.
/// </summary> /// </summary>
[DataField("interactSuccessSound")] [DataField("interactFailureSound")]
public SoundSpecifier? InteractSuccessSound; public SoundSpecifier? InteractFailureSound;
/// <summary> /// <summary>
/// Sound effect to be played when the interaction fails. /// Chance that an interaction attempt will succeed.
/// Nullable in case no path is specified on the yaml prototype. /// 1 = always play "success" popup and sound.
/// </summary> /// 0.5 = 50% chance to play either success or failure popup and sound.
[DataField("interactFailureSound")] /// 0 = always play "failure" popup and sound.
public SoundSpecifier? InteractFailureSound; /// </summary>
[DataField("successChance")]
public float SuccessChance = 1.0f; // Always succeed, unless specified otherwise on the yaml prototype.
/// <summary> /// <summary>
/// Chance that an interaction attempt will succeed. /// If set, shows a message to all surrounding players but NOT the current player.
/// 1 = always play "success" popup and sound. /// </summary>
/// 0.5 = 50% chance to play either success or failure popup and sound. [DataField("messagePerceivedByOthers")]
/// 0 = always play "failure" popup and sound. public string? MessagePerceivedByOthers;
/// </summary>
[DataField("successChance")]
public float SuccessChance = 1.0f; // Always succeed, unless specified otherwise on the yaml prototype.
/// <summary> /// <summary>
/// If set, shows a message to all surrounding players but NOT the current player. /// Will the sound effect be perceived by entities not involved in the interaction?
/// </summary> /// </summary>
[DataField("messagePerceivedByOthers")] [DataField("soundPerceivedByOthers")]
public string? MessagePerceivedByOthers; public bool SoundPerceivedByOthers = true;
/// <summary> [ViewVariables(VVAccess.ReadWrite)]
/// Will the sound effect be perceived by entities not involved in the interaction? public TimeSpan LastInteractTime;
/// </summary> }
[DataField("soundPerceivedByOthers")]
public bool SoundPerceivedByOthers = true;
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan LastInteractTime;
}

View File

@@ -13,8 +13,8 @@ namespace Content.Server.Interaction;
public sealed class InteractionPopupSystem : EntitySystem public sealed class InteractionPopupSystem : EntitySystem
{ {
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -24,7 +24,7 @@ public sealed class InteractionPopupSystem : EntitySystem
private void OnInteractHand(EntityUid uid, InteractionPopupComponent component, InteractHandEvent args) private void OnInteractHand(EntityUid uid, InteractionPopupComponent component, InteractHandEvent args)
{ {
if (args.Handled) if (args.Handled || args.User == args.Target)
return; return;
var curTime = _gameTiming.CurTime; var curTime = _gameTiming.CurTime;