Files
crystall-punk-14/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs

88 lines
2.7 KiB
C#
Raw Normal View History

#nullable enable
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
2021-01-09 12:17:13 +01:00
using Content.Shared.Audio;
2020-05-13 16:53:01 +02:00
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Mobs.State;
using Content.Shared.Interfaces;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
2020-05-13 16:53:01 +02:00
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Timing;
2020-05-13 16:53:01 +02:00
namespace Content.Server.GameObjects.Components.Mobs
{
[RegisterComponent]
2020-06-24 02:21:20 +02:00
[ComponentReference(typeof(SharedStunnableComponent))]
public class StunnableComponent : SharedStunnableComponent, IDisarmedAct
2020-05-13 16:53:01 +02:00
{
2020-07-23 01:40:31 +02:00
protected override void OnKnockdown()
2020-05-13 16:53:01 +02:00
{
EntitySystem.Get<StandingStateSystem>().Down(Owner);
2020-05-13 22:35:23 +02:00
}
protected override void OnKnockdownEnd()
{
if(Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated())
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
}
2020-05-13 19:04:50 +02:00
public void CancelAll()
2020-05-13 16:53:01 +02:00
{
KnockdownTimer = null;
StunnedTimer = null;
2020-06-24 02:21:20 +02:00
Dirty();
2020-06-12 16:22:36 +02:00
}
public void ResetStuns()
{
StunnedTimer = null;
SlowdownTimer = null;
if (KnockedDown &&
Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated())
2020-07-23 01:40:31 +02:00
{
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
2020-07-23 01:40:31 +02:00
}
KnockdownTimer = null;
Dirty();
}
2021-01-09 12:17:13 +01:00
protected override void OnInteractHand()
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/thudswoosh.ogg", Owner, AudioHelpers.WithVariation(0.05f));
2021-01-09 12:17:13 +01:00
}
bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs)
{
if (!IoCManager.Resolve<IRobustRandom>().Prob(eventArgs.PushProbability))
return false;
Paralyze(4f);
var source = eventArgs.Source;
var target = eventArgs.Target;
if (source != null)
{
SoundSystem.Play(Filter.Pvs(source), "/Audio/Effects/thudswoosh.ogg", source,
AudioHelpers.WithVariation(0.025f));
if (target != null)
{
source.PopupMessageOtherClients(Loc.GetString("{0} pushes {1}!", source.Name, target.Name));
source.PopupMessageCursor(Loc.GetString("You push {0}!", target.Name));
}
}
return true;
}
2020-05-13 16:53:01 +02:00
}
}