Improves the RCD (#1609)

* Improves the RCD

* oops

* Unnecessary

* Merge 2 checks

* RCD whitelist and reorganization

* Makes the RCD great again

* Ignored components

* loicense

* Fix missing using
This commit is contained in:
ike709
2020-08-13 12:39:23 -05:00
committed by GitHub
parent 4a8ed41e3a
commit 83a7dfebef
14 changed files with 400 additions and 155 deletions

View File

@@ -0,0 +1,61 @@
using System;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
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
{
#pragma warning disable 649
[Dependency] private IServerNotifyManager _serverNotifyManager;
#pragma warning restore 649
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));
}
void IAfterInteract.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)
{
_serverNotifyManager.PopupMessage(rcdComponent.Owner, eventArgs.User, "The RCD is full!");
return;
}
rcdComponent._ammo = Math.Min(rcdComponent.maxAmmo, rcdComponent._ammo + refillAmmo);
_serverNotifyManager.PopupMessage(rcdComponent.Owner, eventArgs.User, "You refill the RCD.");
//Deleting a held item causes a lot of errors
hands.Drop(Owner, false);
Owner.Delete();
}
}
}