* Moved pen slot to separate component * Moved it all to more generic item slot class * Add sounds * Item slots now supports many slots * Some clean-up * Refactored slots a bit * Moving ID card out * Moving pda to system * Moving PDA owner to ECS * Moved PDA flashlight to separate component * Toggle lights work through events * Fixing UI * Moving uplink to separate component * Continue moving uplink to separate component * More cleaning * Removing pda shared * Nuked shared pda component * Fixed flashlight * Pen slot now showed in UI * Light toggle now shows correctly in UI * Small refactoring of item slots * Added contained entity * Fixed tests * Finished with PDA * Moving PDA uplink to separate window * Adding-removing uplink should show new button * Working on a better debug * Debug command to add uplink * Uplink send state to UI * Almost working UI * Uplink correcty updates when you buy-sell items * Ups * Moved localization to separate file * Minor fixes * Removed item slots methods events * Removed PDA owner name * Removed one uplink event * Deleted all uplink events * Removed flashlight events * Update Content.Shared/Traitor/Uplink/UplinkVisuals.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Containers/ItemSlot/ItemSlotsSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Containers/ItemSlot/ItemSlotsSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameTicking/Presets/PresetTraitorDeathMatch.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Item slots system review * Flashlight review * PDA to XAML * Move UplinkMenu to seperate class, fix WeightedColors methods * Move UI to XAML * Moved events to entity id * Address review * Removed uplink extensions * Minor fix * Moved item slots to shared * My bad Robust... * Fixed pda sound * Fixed pda tests * Fixed pda test again Co-authored-by: Alexander Evgrashin <evgrashin.adl@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Visne <vincefvanwijk@gmail.com>
118 lines
6.3 KiB
C#
118 lines
6.3 KiB
C#
using System.Threading.Tasks;
|
|
using Content.Server.Inventory.Components;
|
|
using Content.Server.Mind.Components;
|
|
using Content.Server.PDA;
|
|
using Content.Server.Traitor.Uplink.Components;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Localization;
|
|
|
|
namespace Content.Server.TraitorDeathMatch.Components
|
|
{
|
|
[RegisterComponent]
|
|
public class TraitorDeathMatchRedemptionComponent : Component, IInteractUsing
|
|
{
|
|
/// <inheritdoc />
|
|
public override string Name => "TraitorDeathMatchRedemption";
|
|
|
|
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
|
{
|
|
if (!eventArgs.User.TryGetComponent<InventoryComponent>(out var userInv))
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-inventory-message"))));
|
|
return false;
|
|
}
|
|
|
|
if (!eventArgs.User.TryGetComponent<MindComponent>(out var userMindComponent))
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-mind-message"))));
|
|
return false;
|
|
}
|
|
|
|
var userMind = userMindComponent.Mind;
|
|
if (userMind == null)
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-user-mind-message"))));
|
|
return false;
|
|
}
|
|
|
|
if (!eventArgs.Using.TryGetComponent<UplinkComponent>(out var victimUplink))
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-message"))));
|
|
return false;
|
|
}
|
|
|
|
if (!eventArgs.Using.TryGetComponent<TraitorDeathMatchReliableOwnerTagComponent>(out var victimPDAOwner))
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-owner-message"))));
|
|
return false;
|
|
}
|
|
|
|
if (victimPDAOwner.UserId == userMind.UserId)
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-pda-different-user-message"))));
|
|
return false;
|
|
}
|
|
|
|
var userPDAEntity = userInv.GetSlotItem(EquipmentSlotDefines.Slots.IDCARD)?.Owner;
|
|
UplinkComponent? userUplink = null;
|
|
|
|
if (userPDAEntity != null)
|
|
if (userPDAEntity.TryGetComponent<UplinkComponent>(out var userUplinkComponent))
|
|
userUplink = userUplinkComponent;
|
|
|
|
if (userUplink == null)
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-in-pocket-message"))));
|
|
return false;
|
|
}
|
|
|
|
// We have finally determined both PDA components. FINALLY.
|
|
|
|
var userAccount = userUplink.UplinkAccount;
|
|
var victimAccount = victimUplink.UplinkAccount;
|
|
|
|
if (userAccount == null)
|
|
{
|
|
// This shouldn't even BE POSSIBLE in the actual mode this is meant for.
|
|
// Advanced Syndicate anti-tampering technology.
|
|
// Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-tampering-detected"));
|
|
// if (eventArgs.User.TryGetComponent<DamagableComponent>(out var userDamagable))
|
|
// userDamagable.ChangeDamage(DamageType.Shock, 9001, true, null);
|
|
// ...So apparently, "it probably shouldn't kill people for a mistake".
|
|
// :(
|
|
// Give boring error message instead.
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-user-no-uplink-account-message"))));
|
|
return false;
|
|
}
|
|
|
|
if (victimAccount == null)
|
|
{
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message",
|
|
("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-victim-no-uplink-account-message"))));
|
|
return false;
|
|
}
|
|
|
|
// 4 is the per-PDA bonus amount.
|
|
var transferAmount = victimAccount.Balance + 4;
|
|
victimAccount.ModifyAccountBalance(0);
|
|
userAccount.ModifyAccountBalance(userAccount.Balance + transferAmount);
|
|
|
|
victimUplink.Owner.Delete();
|
|
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-success-message", ("tcAmount", transferAmount)));
|
|
return true;
|
|
}
|
|
}
|
|
}
|