Event-ify Rejuvenate (#11145)

This commit is contained in:
Visne
2022-09-14 19:30:56 +02:00
committed by GitHub
parent 81eee73995
commit 356a6b8d2e
13 changed files with 100 additions and 61 deletions

View File

@@ -6,6 +6,7 @@ using Content.Shared.Audio;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Rejuvenate;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.Audio;
@@ -19,6 +20,13 @@ namespace Content.Server.Nutrition.EntitySystems
[Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!;
[Dependency] private readonly SpillableSystem _spillableSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CreamPiedComponent, RejuvenateEvent>(OnRejuvenate);
}
protected override void SplattedCreamPie(EntityUid uid, CreamPieComponent creamPie)
{
SoundSystem.Play(creamPie.Sound.GetSound(), Filter.Pvs(creamPie.Owner), creamPie.Owner, AudioHelpers.WithVariation(0.125f));
@@ -36,5 +44,10 @@ namespace Content.Server.Nutrition.EntitySystems
creamPied.Owner.PopupMessage(Loc.GetString("cream-pied-component-on-hit-by-message",("thrower", args.Thrown)));
creamPied.Owner.PopupMessageOtherClients(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", creamPied.Owner),("thrower", args.Thrown)));
}
private void OnRejuvenate(EntityUid uid, CreamPiedComponent component, RejuvenateEvent args)
{
SetCreamPied(uid, component, false);
}
}
}

View File

@@ -1,4 +1,5 @@
using Content.Server.Nutrition.Components;
using Content.Shared.Rejuvenate;
using JetBrains.Annotations;
namespace Content.Server.Nutrition.EntitySystems
@@ -8,6 +9,13 @@ namespace Content.Server.Nutrition.EntitySystems
{
private float _accumulatedFrameTime;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HungerComponent, RejuvenateEvent>(OnRejuvenate);
}
public override void Update(float frameTime)
{
_accumulatedFrameTime += frameTime;
@@ -22,5 +30,10 @@ namespace Content.Server.Nutrition.EntitySystems
_accumulatedFrameTime -= 1;
}
}
private void OnRejuvenate(EntityUid uid, HungerComponent component, RejuvenateEvent args)
{
component.ResetFood();
}
}
}

View File

@@ -4,6 +4,7 @@ using Robust.Shared.Random;
using Content.Shared.Movement.Components;
using Content.Shared.Alert;
using Content.Shared.Movement.Systems;
using Content.Shared.Rejuvenate;
namespace Content.Server.Nutrition.EntitySystems
{
@@ -25,6 +26,7 @@ namespace Content.Server.Nutrition.EntitySystems
_sawmill = Logger.GetSawmill("thirst");
SubscribeLocalEvent<ThirstComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
SubscribeLocalEvent<ThirstComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<ThirstComponent, RejuvenateEvent>(OnRejuvenate);
}
private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args)
{
@@ -47,6 +49,11 @@ namespace Content.Server.Nutrition.EntitySystems
args.ModifySpeed(mod, mod);
}
private void OnRejuvenate(EntityUid uid, ThirstComponent component, RejuvenateEvent args)
{
ResetThirst(component);
}
private ThirstThreshold GetThirstThreshold(ThirstComponent component, float amount)
{
ThirstThreshold result = ThirstThreshold.Dead;