Files
tbd-station-14/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs
Vera Aguilera Puerto 3f79e3754f Merge branch 'master' into 2021-12-03-remove-IEntity-komm-süsser-todd
# Conflicts:
#	Content.Client/Crayon/CrayonDecalVisualizer.cs
#	Content.Client/Tabletop/TabletopSystem.cs
#	Content.IntegrationTests/Tests/InventoryHelpersTest.cs
#	Content.Server/AI/EntitySystems/AiSystem.cs
#	Content.Server/AI/Utility/AiLogic/UtilityAI.cs
#	Content.Server/AME/AMENodeGroup.cs
#	Content.Server/Administration/AdminVerbSystem.cs
#	Content.Server/Body/Systems/RespiratorSystem.cs
#	Content.Server/Chemistry/Components/InjectorComponent.cs
#	Content.Server/Chemistry/TileReactions/CleanTileReaction.cs
#	Content.Server/Chemistry/TileReactions/SpillTileReaction.cs
#	Content.Server/Crayon/CrayonComponent.cs
#	Content.Server/Doors/Components/ServerDoorComponent.cs
#	Content.Server/Explosion/EntitySystems/TriggerSystem.cs
#	Content.Server/Fluids/Components/MopComponent.cs
#	Content.Server/Fluids/Components/SpillExtensions.cs
#	Content.Server/Fluids/EntitySystems/PuddleSystem.cs
#	Content.Server/Instruments/InstrumentSystem.cs
#	Content.Server/Nutrition/EntitySystems/DrinkSystem.cs
#	Content.Server/Nutrition/EntitySystems/FoodSystem.cs
#	Content.Server/PneumaticCannon/PneumaticCannonSystem.cs
#	Content.Server/Storage/Components/EntityStorageComponent.cs
#	Content.Server/Storage/Components/StorageFillComponent.cs
#	Content.Server/Stunnable/StunbatonSystem.cs
#	Content.Server/Throwing/ThrowHelper.cs
#	Content.Server/Weapon/Ranged/Barrels/BarrelSystem.cs
#	Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs
#	Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs
#	Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs
#	Content.Shared/Damage/Components/DamageableComponent.cs
#	Content.Shared/Damage/Systems/DamageableSystem.cs
#	Content.Shared/MobState/Components/MobStateComponent.cs
#	Content.Shared/Slippery/SharedSlipperySystem.cs
2021-12-07 17:48:49 +01:00

77 lines
2.5 KiB
C#

using System;
using Content.Shared.Nutrition.Components;
using Content.Shared.Stunnable;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Shared.Nutrition.EntitySystems
{
[UsedImplicitly]
public abstract class SharedCreamPieSystem : EntitySystem
{
[Dependency] private SharedStunSystem _stunSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CreamPieComponent, ThrowDoHitEvent>(OnCreamPieHit);
SubscribeLocalEvent<CreamPieComponent, LandEvent>(OnCreamPieLand);
SubscribeLocalEvent<CreamPiedComponent, ThrowHitByEvent>(OnCreamPiedHitBy);
}
public void SplatCreamPie(EntityUid uid, CreamPieComponent creamPie)
{
// Already splatted! Do nothing.
if (creamPie.Splatted)
return;
creamPie.Splatted = true;
SplattedCreamPie(uid, creamPie);
EntityManager.QueueDeleteEntity(uid);
}
protected virtual void SplattedCreamPie(EntityUid uid, CreamPieComponent creamPie) {}
public void SetCreamPied(EntityUid uid, CreamPiedComponent creamPied, bool value)
{
if (value == creamPied.CreamPied)
return;
creamPied.CreamPied = value;
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
{
appearance.SetData(CreamPiedVisuals.Creamed, value);
}
}
private void OnCreamPieLand(EntityUid uid, CreamPieComponent component, LandEvent args)
{
SplatCreamPie(uid, component);
}
private void OnCreamPieHit(EntityUid uid, CreamPieComponent component, ThrowDoHitEvent args)
{
SplatCreamPie(uid, component);
}
private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().EntityExists(args.Thrown) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(args.Thrown, out CreamPieComponent? creamPie)) return;
SetCreamPied(uid, creamPied, true);
CreamedEntity(uid, creamPied, args);
_stunSystem.TryParalyze(uid, TimeSpan.FromSeconds(creamPie.ParalyzeTime), true);
}
protected virtual void CreamedEntity(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args) {}
}
}