Files
tbd-station-14/Content.Server/GameObjects/Components/Medical/HealingComponent.cs
DmitriyRubetskoy 9c26e0c5ba Async Interface IAfterInteract() (#2735)
* 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>
2020-12-17 18:45:04 +11:00

64 lines
1.8 KiB
C#

using System.Collections.Generic;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Stack;
using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Medical
{
[RegisterComponent]
public class HealingComponent : Component, IAfterInteract
{
public override string Name => "Healing";
public Dictionary<DamageType, int> Heal { get; private set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, h => h.Heal, "heal", new Dictionary<DamageType, int>());
}
public async Task AfterInteract(AfterInteractEventArgs eventArgs)
{
if (eventArgs.Target == null)
{
return;
}
if (!eventArgs.Target.TryGetComponent(out IDamageableComponent damageable))
{
return;
}
if (!ActionBlockerSystem.CanInteract(eventArgs.User))
{
return;
}
if (eventArgs.User != eventArgs.Target &&
!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
{
return;
}
if (Owner.TryGetComponent(out StackComponent stack) &&
!stack.Use(1))
{
return;
}
foreach (var (type, amount) in Heal)
{
damageable.ChangeDamage(type, -amount, true);
}
}
}
}