* Async Interface * Update Content.Server/GameObjects/Components/Fluids/MopComponent.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Changed the glassbeaker * Update Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Interaction system fix * Removed I from the interface * Changed all implementations of the interface I could find * all public void implementation fixed * All built, no errors should remain * Update Resources/Prototypes/Entities/Objects/Specific/chemistry.yml Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/ActionBlocking/HandcuffComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Commit based off Sloth's commentary * Removed the Rag file from the PR * Reverted sloth's commentary changes on the publcity of the function * Injector component properly implemented interface * Update Content.Server/GameObjects/Components/Fluids/MopComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/Fluids/SprayComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: BlueberryShortcake <rubetskoy234@mail.ru> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Content.Server.Interfaces.GameObjects.Components.Items;
|
|
using Content.Shared.GameObjects.EntitySystems;
|
|
using Content.Shared.Interfaces;
|
|
using Content.Shared.Interfaces.GameObjects.Components;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Localization;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Utility;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Server.GameObjects.Components.Items.RCD
|
|
{
|
|
[RegisterComponent]
|
|
public class RCDAmmoComponent : Component, IAfterInteract, IExamine
|
|
{
|
|
public override string Name => "RCDAmmo";
|
|
|
|
//How much ammo we refill
|
|
[ViewVariables(VVAccess.ReadWrite)] private int refillAmmo = 5;
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
|
|
serializer.DataField(ref refillAmmo, "refillAmmo", 5);
|
|
}
|
|
|
|
public void Examine(FormattedMessage message, bool inDetailsRange)
|
|
{
|
|
message.AddMarkup(Loc.GetString("It holds {0} charges.", refillAmmo));
|
|
}
|
|
|
|
public async Task AfterInteract(AfterInteractEventArgs eventArgs)
|
|
{
|
|
if (eventArgs.Target == null || !eventArgs.Target.TryGetComponent(out RCDComponent rcdComponent) || !eventArgs.User.TryGetComponent(out IHandsComponent hands))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (rcdComponent.maxAmmo - rcdComponent._ammo < refillAmmo)
|
|
{
|
|
rcdComponent.Owner.PopupMessage(eventArgs.User, Loc.GetString("The RCD is full!"));
|
|
return;
|
|
}
|
|
|
|
rcdComponent._ammo = Math.Min(rcdComponent.maxAmmo, rcdComponent._ammo + refillAmmo);
|
|
rcdComponent.Owner.PopupMessage(eventArgs.User, Loc.GetString("You refill the RCD."));
|
|
|
|
//Deleting a held item causes a lot of errors
|
|
hands.Drop(Owner, false);
|
|
Owner.Delete();
|
|
}
|
|
}
|
|
}
|