2021-03-31 12:41:23 -07:00
|
|
|
#nullable enable
|
2021-02-20 15:55:35 -07:00
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
2021-01-09 20:31:34 +01:00
|
|
|
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;
|
2021-02-20 15:55:35 -07:00
|
|
|
using Content.Shared.GameObjects.Components.Mobs.State;
|
2021-01-09 20:31:34 +01:00
|
|
|
using Content.Shared.Interfaces;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.GameObjects;
|
2021-03-21 09:12:03 -07:00
|
|
|
using Robust.Shared.Audio;
|
2020-05-13 16:53:01 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
2021-01-09 20:31:34 +01:00
|
|
|
using Robust.Shared.Localization;
|
2021-03-21 09:12:03 -07:00
|
|
|
using Robust.Shared.Player;
|
|
|
|
|
using Robust.Shared.Players;
|
2021-01-09 20:31:34 +01:00
|
|
|
using Robust.Shared.Random;
|
2021-02-11 01:13:03 -08:00
|
|
|
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))]
|
2021-01-09 20:31:34 +01:00
|
|
|
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
|
|
|
{
|
2020-08-29 13:20:37 +02:00
|
|
|
EntitySystem.Get<StandingStateSystem>().Down(Owner);
|
2020-05-13 22:35:23 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-08 05:00:50 +01: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
|
|
|
{
|
2021-03-08 05:00:50 +01:00
|
|
|
KnockdownTimer = null;
|
|
|
|
|
StunnedTimer = null;
|
2020-06-24 02:21:20 +02:00
|
|
|
Dirty();
|
2020-06-12 16:22:36 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-23 21:05:25 +02:00
|
|
|
public void ResetStuns()
|
|
|
|
|
{
|
2021-03-08 05:00:50 +01:00
|
|
|
StunnedTimer = null;
|
|
|
|
|
SlowdownTimer = null;
|
2020-06-23 21:05:25 +02:00
|
|
|
|
2021-02-20 15:55:35 -07:00
|
|
|
if (KnockedDown &&
|
|
|
|
|
Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated())
|
2020-07-23 01:40:31 +02:00
|
|
|
{
|
2020-08-29 13:20:37 +02:00
|
|
|
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
|
2020-07-23 01:40:31 +02:00
|
|
|
}
|
2020-06-23 21:05:25 +02:00
|
|
|
|
2021-03-08 05:00:50 +01:00
|
|
|
KnockdownTimer = null;
|
2021-02-12 11:53:10 +01:00
|
|
|
Dirty();
|
2020-06-23 21:05:25 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-09 12:17:13 +01:00
|
|
|
protected override void OnInteractHand()
|
|
|
|
|
{
|
2021-03-21 09:12:03 -07:00
|
|
|
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/thudswoosh.ogg", Owner, AudioHelpers.WithVariation(0.05f));
|
2021-01-09 12:17:13 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-09 20:31:34 +01:00
|
|
|
bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs)
|
|
|
|
|
{
|
|
|
|
|
if (!IoCManager.Resolve<IRobustRandom>().Prob(eventArgs.PushProbability))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
Paralyze(4f);
|
|
|
|
|
|
|
|
|
|
var source = eventArgs.Source;
|
2021-03-16 15:50:20 +01:00
|
|
|
var target = eventArgs.Target;
|
2021-01-09 20:31:34 +01:00
|
|
|
|
2021-03-16 15:50:20 +01:00
|
|
|
if (source != null)
|
|
|
|
|
{
|
2021-03-21 09:12:03 -07:00
|
|
|
SoundSystem.Play(Filter.Pvs(source), "/Audio/Effects/thudswoosh.ogg", source,
|
2021-03-16 15:50:20 +01:00
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-09 20:31:34 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-05-13 16:53:01 +02:00
|
|
|
}
|
|
|
|
|
}
|