2021-08-21 09:18:23 +02:00
|
|
|
using Content.Shared.Nutrition.Components;
|
|
|
|
|
using Content.Shared.Stunnable;
|
|
|
|
|
using Content.Shared.Throwing;
|
2024-01-28 18:37:24 +07:00
|
|
|
using Content.Shared._White.Mood;
|
2021-08-21 09:18:23 +02:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Nutrition.EntitySystems
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
public abstract class SharedCreamPieSystem : EntitySystem
|
|
|
|
|
{
|
2021-10-10 12:47:26 +02:00
|
|
|
[Dependency] private SharedStunSystem _stunSystem = default!;
|
2023-02-02 17:34:53 +01:00
|
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
2021-10-10 12:47:26 +02:00
|
|
|
|
2021-08-21 09:18:23 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2021-11-22 23:22:59 -08:00
|
|
|
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
|
2021-08-21 09:18:23 +02:00
|
|
|
{
|
2023-02-02 17:34:53 +01:00
|
|
|
_appearance.SetData(uid, CreamPiedVisuals.Creamed, value, appearance);
|
2021-08-21 09:18:23 +02:00
|
|
|
}
|
2023-09-25 01:44:44 +03:00
|
|
|
|
|
|
|
|
RaiseLocalEvent(uid, new MoodEffectEvent("Creampied")); // WD edit
|
2021-08-21 09:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-18 05:25:32 +11:00
|
|
|
private void OnCreamPieLand(EntityUid uid, CreamPieComponent component, ref LandEvent args)
|
2021-08-21 09:18:23 +02:00
|
|
|
{
|
|
|
|
|
SplatCreamPie(uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCreamPieHit(EntityUid uid, CreamPieComponent component, ThrowDoHitEvent args)
|
|
|
|
|
{
|
|
|
|
|
SplatCreamPie(uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args)
|
|
|
|
|
{
|
2021-12-08 13:00:43 +01:00
|
|
|
if (!EntityManager.EntityExists(args.Thrown) || !EntityManager.TryGetComponent(args.Thrown, out CreamPieComponent? creamPie)) return;
|
2021-08-21 09:18:23 +02:00
|
|
|
|
|
|
|
|
SetCreamPied(uid, creamPied, true);
|
|
|
|
|
|
|
|
|
|
CreamedEntity(uid, creamPied, args);
|
|
|
|
|
|
2021-12-07 09:18:07 +03:00
|
|
|
_stunSystem.TryParalyze(uid, TimeSpan.FromSeconds(creamPie.ParalyzeTime), true);
|
2021-08-21 09:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void CreamedEntity(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args) {}
|
|
|
|
|
}
|
|
|
|
|
}
|