Move RCD to ECS (#4742)

* Moved ammo to ecs

* Moved RCD to ecs

* Replaced RCDDeconstructWhitelist with Tag

* Updated new structures RCDDeconstructWhitelist

* Queue delete
This commit is contained in:
Alex Evgrashin
2021-10-24 06:34:00 +03:00
committed by GitHub
parent f6803eb324
commit 7de1ebbd77
12 changed files with 378 additions and 306 deletions

View File

@@ -1,52 +1,15 @@
using System;
using System.Threading.Tasks;
using Content.Server.Hands.Components;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
namespace Content.Server.RCD.Components
{
[RegisterComponent]
public class RCDAmmoComponent : Component, IAfterInteract, IExamine
public class RCDAmmoComponent : Component
{
public override string Name => "RCDAmmo";
//How much ammo we refill
[ViewVariables(VVAccess.ReadWrite)] [DataField("refillAmmo")] private int refillAmmo = 5;
public void Examine(FormattedMessage message, bool inDetailsRange)
{
message.AddMarkup(Loc.GetString("rcd-ammo-component-on-examine-text",("ammo", refillAmmo)));
}
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
{
if (eventArgs.Target == null ||
!eventArgs.Target.TryGetComponent(out RCDComponent? rcdComponent) ||
!eventArgs.User.TryGetComponent(out IHandsComponent? hands))
{
return false;
}
if (rcdComponent.MaxAmmo - rcdComponent._ammo < refillAmmo)
{
rcdComponent.Owner.PopupMessage(eventArgs.User, Loc.GetString("rcd-ammo-component-after-interact-full-text"));
return true;
}
rcdComponent._ammo = Math.Min(rcdComponent.MaxAmmo, rcdComponent._ammo + refillAmmo);
rcdComponent.Owner.PopupMessage(eventArgs.User, Loc.GetString("rcd-ammo-component-after-interact-refilled-text"));
//Deleting a held item causes a lot of errors
hands.Drop(Owner, false);
Owner.Delete();
return true;
}
[ViewVariables(VVAccess.ReadWrite)] [DataField("refillAmmo")] public int RefillAmmo = 5;
}
}