Refactors throw events, makes cream pies ECS (#4500)
This commit is contained in:
committed by
GitHub
parent
140682f92b
commit
ea4ce1c6fc
@@ -1,53 +0,0 @@
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Nutrition.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class CreamPieComponent : Component, ILand, IThrowCollide
|
||||
{
|
||||
public override string Name => "CreamPie";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("paralyzeTime")]
|
||||
public float ParalyzeTime { get; set; } = 1f;
|
||||
|
||||
[DataField("sound")]
|
||||
private SoundSpecifier _sound = new SoundCollectionSpecifier("desecration");
|
||||
|
||||
public void PlaySound()
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
|
||||
void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs)
|
||||
{
|
||||
Splat();
|
||||
}
|
||||
|
||||
void ILand.Land(LandEventArgs eventArgs)
|
||||
{
|
||||
Splat();
|
||||
}
|
||||
|
||||
public void Splat()
|
||||
{
|
||||
PlaySound();
|
||||
|
||||
if (Owner.TryGetComponent(out SolutionContainerComponent? solution))
|
||||
{
|
||||
solution.Solution.SpillAt(Owner, "PuddleSmear", false);
|
||||
}
|
||||
|
||||
Owner.QueueDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using Content.Server.Notification;
|
||||
using Content.Server.Stunnable.Components;
|
||||
using Content.Shared.Notification;
|
||||
using Content.Shared.Notification.Managers;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Nutrition.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class CreamPiedComponent : SharedCreamPiedComponent, IThrowCollide
|
||||
{
|
||||
private bool _creamPied;
|
||||
|
||||
[ViewVariables]
|
||||
public bool CreamPied
|
||||
{
|
||||
get => _creamPied;
|
||||
private set
|
||||
{
|
||||
if (value == _creamPied) return;
|
||||
|
||||
_creamPied = value;
|
||||
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(CreamPiedVisuals.Creamed, CreamPied);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Wash()
|
||||
{
|
||||
if(CreamPied)
|
||||
CreamPied = false;
|
||||
}
|
||||
|
||||
void IThrowCollide.HitBy(ThrowCollideEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Thrown.Deleted || !eventArgs.Thrown.TryGetComponent(out CreamPieComponent? creamPie)) return;
|
||||
|
||||
CreamPied = true;
|
||||
Owner.PopupMessage(Loc.GetString("cream-pied-component-on-hit-by-message",("thrower", eventArgs.Thrown)));
|
||||
Owner.PopupMessageOtherClients(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", Owner),("thrower", eventArgs.Thrown)));
|
||||
|
||||
if (Owner.TryGetComponent(out StunnableComponent? stun))
|
||||
{
|
||||
stun.Paralyze(creamPie.ParalyzeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user