Adds IThrowCollide, Creaming people with cream pies and tactical stun baton throws (#2122)
This commit is contained in:
committed by
GitHub
parent
db32180942
commit
4c34a12c67
@@ -27,7 +27,7 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Server.GameObjects.Components.Fluids
|
||||
{
|
||||
[RegisterComponent]
|
||||
class SprayComponent : SharedSprayComponent, IAfterInteract, IUse, IActivate
|
||||
class SprayComponent : SharedSprayComponent, IAfterInteract, IUse, IActivate, IDropped
|
||||
{
|
||||
public const float SprayDistance = 3f;
|
||||
|
||||
@@ -211,5 +211,11 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
if(Owner.TryGetComponent(out AppearanceComponent appearance))
|
||||
appearance.SetData(SprayVisuals.Safety, _safety);
|
||||
}
|
||||
|
||||
public void Dropped(DroppedEventArgs eventArgs)
|
||||
{
|
||||
if(_hasSafety && Owner.TryGetComponent(out AppearanceComponent appearance))
|
||||
appearance.SetData(SprayVisuals.Safety, _safety);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using Content.Server.GameObjects.Components.Chemistry;
|
||||
using Content.Server.GameObjects.Components.Fluids;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Nutrition
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class CreamPieComponent : Component, ILand
|
||||
{
|
||||
public override string Name => "CreamPie";
|
||||
|
||||
public void PlaySound()
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>()
|
||||
.PlayFromEntity(AudioHelpers.GetRandomFileFromSoundCollection("desecration"), Owner,
|
||||
AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
|
||||
public void Land(LandEventArgs eventArgs)
|
||||
{
|
||||
PlaySound();
|
||||
|
||||
if (Owner.TryGetComponent(out SolutionContainerComponent solution))
|
||||
{
|
||||
solution.Solution.SpillAt(Owner, "PuddleSmear", false);
|
||||
}
|
||||
|
||||
Owner.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.GameObjects.Components.Nutrition;
|
||||
using Content.Shared.Interfaces;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Serilog;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Nutrition
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class CreamPiedComponent : SharedCreamPiedComponent, IReagentReaction, IThrowCollide
|
||||
{
|
||||
private bool _creamPied;
|
||||
|
||||
[ViewVariables]
|
||||
public bool CreamPied
|
||||
{
|
||||
get => _creamPied;
|
||||
private set
|
||||
{
|
||||
_creamPied = value;
|
||||
if (Owner.TryGetComponent(out AppearanceComponent appearance))
|
||||
{
|
||||
appearance.SetData(CreamPiedVisuals.Creamed, CreamPied);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Wash()
|
||||
{
|
||||
if(CreamPied)
|
||||
CreamPied = false;
|
||||
}
|
||||
|
||||
public ReagentUnit ReagentReactTouch(ReagentPrototype reagent, ReagentUnit volume)
|
||||
{
|
||||
switch (reagent.ID)
|
||||
{
|
||||
case "chem.SpaceCleaner":
|
||||
case "chem.H2O":
|
||||
Wash();
|
||||
break;
|
||||
}
|
||||
|
||||
return ReagentUnit.Zero;
|
||||
}
|
||||
|
||||
public void HitBy(ThrowCollideEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.Thrown.TryGetComponent(out CreamPieComponent creamPie) || CreamPied) return;
|
||||
|
||||
CreamPied = true;
|
||||
Owner.PopupMessage(Loc.GetString("You have been creamed by {0:theName}!", eventArgs.Thrown));
|
||||
Owner.PopupMessageOtherClients(Loc.GetString("{0:theName} has been creamed by {1:theName}!", Owner, eventArgs.Thrown));
|
||||
|
||||
if (Owner.TryGetComponent(out StunnableComponent stun))
|
||||
{
|
||||
stun.Paralyze(1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
return;
|
||||
|
||||
_shouldStop = true; // hit something hard => stop after this collision
|
||||
|
||||
// Raise an event.
|
||||
EntitySystem.Get<InteractionSystem>().ThrowCollideInteraction(User, Owner, entity, Owner.Transform.Coordinates);
|
||||
}
|
||||
if (entity.TryGetComponent(out IDamageableComponent damage))
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class StunbatonComponent : MeleeWeaponComponent, IUse, IExamine, IMapInit, IInteractUsing
|
||||
public class StunbatonComponent : MeleeWeaponComponent, IUse, IExamine, IMapInit, IInteractUsing, IThrowCollide
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
|
||||
@@ -282,5 +282,15 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
component.EjectCell(user);
|
||||
}
|
||||
}
|
||||
|
||||
public void DoHit(ThrowCollideEventArgs eventArgs)
|
||||
{
|
||||
if (!Activated || Cell == null || !Cell.TryUseCharge(EnergyPerUse) || !eventArgs.Target.TryGetComponent(out StunnableComponent stunnable))
|
||||
return;
|
||||
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Weapons/egloves.ogg", Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
|
||||
|
||||
stunnable.Paralyze(_paralyzeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user