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

@@ -1,23 +1,19 @@
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Miasma;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Disease.Components;
using Content.Server.Disease;
using Content.Server.MobState;
using Content.Server.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Administration;
using Content.Shared.Damage;
using Content.Shared.Jittering;
using Content.Shared.MobState.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Rejuvenate;
using Content.Shared.StatusEffect;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Admin)]
@@ -56,47 +52,8 @@ namespace Content.Server.Administration.Commands
public static void PerformRejuvenate(EntityUid target)
{
var targetUid = target;
var entMan = IoCManager.Resolve<IEntityManager>();
entMan.GetComponentOrNull<HungerComponent>(targetUid)?.ResetFood();
// TODO holy shit make this an event my man!
EntitySystem.Get<StatusEffectsSystem>().TryRemoveAllStatusEffects(target);
if(entMan.TryGetComponent(target , out ThirstComponent? thirst))
{
EntitySystem.Get<ThirstSystem>().ResetThirst(thirst);
}
if (entMan.TryGetComponent(target, out FlammableComponent? flammable))
{
EntitySystem.Get<FlammableSystem>().Extinguish(target, flammable);
}
if (entMan.TryGetComponent(target, out DamageableComponent? damageable))
{
EntitySystem.Get<DamageableSystem>().SetAllDamage(damageable, 0);
}
if (entMan.TryGetComponent(target, out CreamPiedComponent? creamPied))
{
EntitySystem.Get<CreamPieSystem>().SetCreamPied(target, creamPied, false);
}
if (entMan.TryGetComponent(target, out BloodstreamComponent? bloodStream))
{
var sys = EntitySystem.Get<BloodstreamSystem>();
sys.TryModifyBleedAmount(target, -bloodStream.BleedAmount, bloodStream);
sys.TryModifyBloodLevel(target, bloodStream.BloodSolution.AvailableVolume, bloodStream);
}
if (entMan.TryGetComponent<DiseaseCarrierComponent>(target, out var carrier))
{
EntitySystem.Get<DiseaseSystem>().CureAllDiseases(target, carrier);
}
entMan.RemoveComponent<JitteringComponent>(target);
entMan.RemoveComponent<RottingComponent>(target);
var entityManager = IoCManager.Resolve<IEntityManager>();
entityManager.EventBus.RaiseLocalEvent(target, new RejuvenateEvent());
}
}
}

View File

@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components;
using Content.Server.Stunnable;
@@ -14,11 +12,9 @@ using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Rejuvenate;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
@@ -55,10 +51,11 @@ namespace Content.Server.Atmos.EntitySystems
UpdatesAfter.Add(typeof(AtmosphereSystem));
SubscribeLocalEvent<FlammableComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<FlammableComponent, InteractUsingEvent>(OnInteractUsingEvent);
SubscribeLocalEvent<FlammableComponent, StartCollideEvent>(OnCollideEvent);
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHotEvent);
SubscribeLocalEvent<FlammableComponent, TileFireEvent>(OnTileFireEvent);
SubscribeLocalEvent<FlammableComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<FlammableComponent, StartCollideEvent>(OnCollide);
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHot);
SubscribeLocalEvent<FlammableComponent, TileFireEvent>(OnTileFire);
SubscribeLocalEvent<FlammableComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<IgniteOnCollideComponent, StartCollideEvent>(IgniteOnCollide);
SubscribeLocalEvent<IgniteOnMeleeHitComponent, MeleeHitEvent>(OnMeleeHit);
}
@@ -73,7 +70,6 @@ namespace Content.Server.Atmos.EntitySystems
flammable.FireStacks += component.FireStacks;
Ignite(entity, flammable);
}
}
private void IgniteOnCollide(EntityUid uid, IgniteOnCollideComponent component, ref StartCollideEvent args)
@@ -104,7 +100,7 @@ namespace Content.Server.Atmos.EntitySystems
});
}
private void OnInteractUsingEvent(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
private void OnInteractUsing(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
{
if (args.Handled)
return;
@@ -119,7 +115,7 @@ namespace Content.Server.Atmos.EntitySystems
args.Handled = true;
}
private void OnCollideEvent(EntityUid uid, FlammableComponent flammable, ref StartCollideEvent args)
private void OnCollide(EntityUid uid, FlammableComponent flammable, ref StartCollideEvent args)
{
var otherUid = args.OtherFixture.Body.Owner;
@@ -157,12 +153,12 @@ namespace Content.Server.Atmos.EntitySystems
}
}
private void OnIsHotEvent(EntityUid uid, FlammableComponent flammable, IsHotEvent args)
private void OnIsHot(EntityUid uid, FlammableComponent flammable, IsHotEvent args)
{
args.IsHot = flammable.OnFire;
}
private void OnTileFireEvent(EntityUid uid, FlammableComponent flammable, ref TileFireEvent args)
private void OnTileFire(EntityUid uid, FlammableComponent flammable, ref TileFireEvent args)
{
var tempDelta = args.Temperature - MinIgnitionTemperature;
@@ -173,6 +169,11 @@ namespace Content.Server.Atmos.EntitySystems
_fireEvents[flammable] = tempDelta;
}
private void OnRejuvenate(EntityUid uid, FlammableComponent component, RejuvenateEvent args)
{
Extinguish(uid, component);
}
public void UpdateAppearance(EntityUid uid, FlammableComponent? flammable = null, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref flammable, ref appearance))

View File

@@ -5,6 +5,7 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Temperature.Systems;
using Content.Server.Body.Components;
using Content.Shared.Examine;
using Content.Shared.Rejuvenate;
using Robust.Server.GameObjects;
using Content.Shared.Tag;
using Robust.Shared.Containers;
@@ -132,6 +133,7 @@ namespace Content.Server.Atmos.Miasma
SubscribeLocalEvent<PerishableComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<PerishableComponent, BeingGibbedEvent>(OnGibbed);
SubscribeLocalEvent<PerishableComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<RottingComponent, RejuvenateEvent>(OnRejuvenate);
// Containers
SubscribeLocalEvent<AntiRottingContainerComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
SubscribeLocalEvent<AntiRottingContainerComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
@@ -198,6 +200,11 @@ namespace Content.Server.Atmos.Miasma
args.PushMarkup(Loc.GetString(description));
}
private void OnRejuvenate(EntityUid uid, RottingComponent component, RejuvenateEvent args)
{
EntityManager.RemoveComponentDeferred<RottingComponent>(uid);
}
/// Containers
private void OnEntInserted(EntityUid uid, AntiRottingContainerComponent component, EntInsertedIntoContainerMessage args)

View File

@@ -1,9 +1,9 @@
namespace Content.Server.Atmos.Miasma
{
[RegisterComponent]
/// <summary>
/// Tracking component for stuff that has started to rot.
/// </summary>
[RegisterComponent]
public sealed class RottingComponent : Component
{
/// <summary>

View File

@@ -13,6 +13,7 @@ using Content.Shared.IdentityManagement;
using Content.Shared.MobState.Components;
using Content.Shared.Popups;
using Content.Shared.Drunk;
using Content.Shared.Rejuvenate;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
@@ -45,6 +46,7 @@ public sealed class BloodstreamSystem : EntitySystem
SubscribeLocalEvent<BloodstreamComponent, BeingGibbedEvent>(OnBeingGibbed);
SubscribeLocalEvent<BloodstreamComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
SubscribeLocalEvent<BloodstreamComponent, ReactionAttemptEvent>(OnReactionAttempt);
SubscribeLocalEvent<BloodstreamComponent, RejuvenateEvent>(OnRejuvenate);
}
private void OnReactionAttempt(EntityUid uid, BloodstreamComponent component, ReactionAttemptEvent args)
@@ -216,6 +218,12 @@ public sealed class BloodstreamSystem : EntitySystem
component.AccumulatedFrametime = component.UpdateInterval;
}
private void OnRejuvenate(EntityUid uid, BloodstreamComponent component, RejuvenateEvent args)
{
TryModifyBleedAmount(uid, -component.BleedAmount, component);
TryModifyBloodLevel(uid, component.BloodSolution.AvailableVolume, component);
}
/// <summary>
/// Attempt to transfer provided solution to internal solution.
/// </summary>

View File

@@ -21,6 +21,7 @@ using Robust.Shared.Utility;
using Content.Shared.IdentityManagement;
using Content.Shared.Item;
using Content.Server.MobState;
using Content.Shared.Rejuvenate;
namespace Content.Server.Disease
{
@@ -44,6 +45,7 @@ namespace Content.Server.Disease
base.Initialize();
SubscribeLocalEvent<DiseaseCarrierComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<DiseaseCarrierComponent, CureDiseaseAttemptEvent>(OnTryCureDisease);
SubscribeLocalEvent<DiseaseCarrierComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<DiseasedComponent, UserInteractedWithItemEvent>(OnUserInteractDiseased);
SubscribeLocalEvent<DiseasedComponent, ItemInteractedWithEvent>(OnTargetInteractDiseased);
SubscribeLocalEvent<DiseasedComponent, EntitySpokeEvent>(OnEntitySpeak);
@@ -188,6 +190,11 @@ namespace Content.Server.Disease
}
}
private void OnRejuvenate(EntityUid uid, DiseaseCarrierComponent component, RejuvenateEvent args)
{
CureAllDiseases(uid, component);
}
/// <summary>
/// Called when a component with disease protection
/// is equipped so it can be added to the person's

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;

View File

@@ -5,6 +5,7 @@ using Content.Shared.Inventory;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Radiation.Events;
using Content.Shared.Rejuvenate;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
@@ -21,6 +22,7 @@ namespace Content.Shared.Damage
SubscribeLocalEvent<DamageableComponent, ComponentHandleState>(DamageableHandleState);
SubscribeLocalEvent<DamageableComponent, ComponentGetState>(DamageableGetState);
SubscribeLocalEvent<DamageableComponent, OnIrradiatedEvent>(OnIrradiated);
SubscribeLocalEvent<DamageableComponent, RejuvenateEvent>(OnRejuvenate);
}
/// <summary>
@@ -245,6 +247,11 @@ namespace Content.Shared.Damage
TryChangeDamage(uid, damage);
}
private void OnRejuvenate(EntityUid uid, DamageableComponent component, RejuvenateEvent args)
{
SetAllDamage(component, 0);
}
private void DamageableHandleState(EntityUid uid, DamageableComponent component, ref ComponentHandleState args)
{
if (args.Current is not DamageableComponentState state)

View File

@@ -1,3 +1,4 @@
using Content.Shared.Rejuvenate;
using Content.Shared.StatusEffect;
using Robust.Shared.GameStates;
using Robust.Shared.Timing;
@@ -22,6 +23,7 @@ namespace Content.Shared.Jittering
{
SubscribeLocalEvent<JitteringComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<JitteringComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<JitteringComponent, RejuvenateEvent>(OnRejuvenate);
}
private void OnGetState(EntityUid uid, JitteringComponent component, ref ComponentGetState args)
@@ -38,6 +40,11 @@ namespace Content.Shared.Jittering
component.Frequency = jitteringState.Frequency;
}
private void OnRejuvenate(EntityUid uid, JitteringComponent component, RejuvenateEvent args)
{
EntityManager.RemoveComponentDeferred<JitteringComponent>(uid);
}
/// <summary>
/// Applies a jitter effect to the specified entity.
/// You can apply this to any entity whatsoever, so be careful what you use it on!

View File

@@ -0,0 +1,5 @@
namespace Content.Shared.Rejuvenate;
public sealed class RejuvenateEvent : EntityEventArgs
{
}

View File

@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Alert;
using Content.Shared.Rejuvenate;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
@@ -22,6 +23,7 @@ namespace Content.Shared.StatusEffect
SubscribeLocalEvent<StatusEffectsComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<StatusEffectsComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<StatusEffectsComponent, RejuvenateEvent>(OnRejuvenate);
}
public override void Update(float frameTime)
@@ -82,6 +84,11 @@ namespace Content.Shared.StatusEffect
}
}
private void OnRejuvenate(EntityUid uid, StatusEffectsComponent component, RejuvenateEvent args)
{
TryRemoveAllStatusEffects(uid, component);
}
/// <summary>
/// Tries to add a status effect to an entity, with a given component added as well.
/// </summary>