Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abilities #293

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions Content.Server/Stories/Abilities/AbilitiesSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using Content.Server.Administration.Systems;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Emp;
using Content.Server.Flash;
using Content.Server.Lightning;
using Content.Shared.Speech.Muting;
using Content.Shared.StatusEffect;
using Content.Shared.Stories.Abilities;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;

namespace Content.Server.Stories.Abilities;

public sealed partial class AbilitiesSystem : SharedAbilitiesSystem
{
[Dependency] private readonly LightningSystem _lightning = default!;
[Dependency] private readonly FlammableSystem _flammable = default!;
[Dependency] private readonly EmpSystem _emp = default!;
[Dependency] private readonly RejuvenateSystem _rejuvenate = default!;
[Dependency] private readonly SharedTransformSystem _xform = default!;
[Dependency] private readonly FlashSystem _flash = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;

public readonly ProtoId<StatusEffectPrototype> MutedStatusEffect = "Muted";

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RejuvenateActionEvent>(OnRejuvenate);
SubscribeLocalEvent<EmpActionEvent>(OnEmp);
SubscribeLocalEvent<IgniteTargetActionEvent>(OnIgnite);
SubscribeLocalEvent<ShootLightningsTargetEvent>(OnLightning);
SubscribeLocalEvent<FlashAreaEvent>(OnFlashAreaEvent);
SubscribeLocalEvent<RangedGlareEvent>(OnRangedGlare);
}

private void OnRangedGlare(RangedGlareEvent args)
{
if (args.Handled)
return;

var modifier = args.RequiredRange / (_xform.GetMapCoordinates(args.Performer).Position - _xform.GetMapCoordinates(args.Target).Position).Length();
modifier = modifier < 1 ? modifier : 1;

_flash.Flash(args.Target, args.Performer, null, args.Duration * modifier, args.SlowTo * modifier, false);
_statusEffects.TryAddStatusEffect<MutedComponent>(args.Target, MutedStatusEffect, TimeSpan.FromSeconds(args.Duration * modifier / 1000f), true);

args.Handled = true;
}

private void OnFlashAreaEvent(FlashAreaEvent args)
{
if (args.Handled)
return;

_flash.FlashArea(args.Performer, args.Performer, args.Range, args.FlashDuration, slowTo: args.SlowTo, sound: args.Sound);

args.Handled = true;
}

private void OnLightning(ShootLightningsTargetEvent args)
{
if (args.Handled)
return;

var performerCoords = _xform.GetMapCoordinates(args.Performer);
HashSet<MapCoordinates> lightningsCoords = new();

foreach (var vector in args.Vectors)
{
lightningsCoords.Add(new MapCoordinates(performerCoords.Position + vector, performerCoords.MapId));
}

foreach (var coordinates in lightningsCoords)
{
var user = Spawn(null, coordinates);
_lightning.ShootLightning(user, args.Target, args.LightningPrototype, args.TriggerLightningEvents);
}

args.Handled = true;
}

private void OnRejuvenate(RejuvenateActionEvent args)
{
if (args.Handled)
return;

_rejuvenate.PerformRejuvenate(args.Performer);

args.Handled = true;
}

private void OnIgnite(IgniteTargetActionEvent args)
{
if (args.Handled)
return;

_flammable.AdjustFireStacks(args.Target, args.StackAmount);
_flammable.Ignite(args.Target, args.Performer);

args.Handled = true;
}

private void OnEmp(EmpActionEvent args)
{
if (args.Handled)
return;

_emp.EmpPulse(_xform.GetMapCoordinates(args.Performer), args.Range, args.EnergyConsumption, args.DisableDuration);

args.Handled = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,5 @@
namespace Content.Server.Stories.ForceUser;
public sealed partial class ForceUserSystem
{
public void InitializeLightning()
{
SubscribeLocalEvent<LightningStrikeEvent>(OnLightning);
}
private void OnLightning(LightningStrikeEvent args)
{
if (args.Handled)
return;

var xform = Transform(args.Performer);

var coord = _xform.GetMapCoordinates(xform);

HashSet<MapCoordinates> coords = new()
{
new MapCoordinates(coord.Position + new Vector2(0, 1), coord.MapId),
new MapCoordinates(coord.Position + new Vector2(1, -1), coord.MapId),
new MapCoordinates(coord.Position + new Vector2(-1, -1), coord.MapId)
};

foreach (var coordinates in coords)
{
var user = Spawn(null, coordinates);
_lightning.ShootLightning(user, args.Target);
}

args.Handled = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ public sealed partial class ForceUserSystem
{
public void InitializeSimpleActions()
{
SubscribeLocalEvent<FlashAreaEvent>(OnFlashAreaEvent);
SubscribeLocalEvent<EmpActionEvent>(OnEmp);
SubscribeLocalEvent<RejuvenateActionEvent>(OnRejuvenate);
SubscribeLocalEvent<FreedomActionEvent>(OnFreedom);
// SubscribeLocalEvent<LightningStrikeEvent>(OnStrike);
SubscribeLocalEvent<IgniteTargetActionEvent>(OnIgnite);
SubscribeLocalEvent<RecliningPulseEvent>(OnPulseEvent);
SubscribeLocalEvent<ForceDashActionEvent>(OnDash);

SubscribeLocalEvent<HypnosisTargetActionEvent>(OnHypnosis); // FIXME: Тут не должно быть этого - start
SubscribeLocalEvent<ForceUserComponent, FrozeBulletsActionEvent>(OnFrozeBullets);
SubscribeLocalEvent<ForceUserComponent, ForceShopActionEvent>(OnShop);
Expand Down Expand Up @@ -58,84 +49,10 @@ private void OnShop(EntityUid uid, ForceUserComponent component, ForceShopAction
return;
_store.ToggleUi(uid, uid, store);
}
private void OnRejuvenate(RejuvenateActionEvent args)
{
if (args.Handled) return;
_rejuvenate.PerformRejuvenate(args.Performer);
args.Handled = true;
}
private void OnPulseEvent(RecliningPulseEvent args)
{
if (args.Handled) return;

var xform = Transform(args.Performer);
var range = args.Range;
var strength = args.Strength;
var lookup = _lookup.GetEntitiesInRange(args.Performer, range, LookupFlags.Dynamic | LookupFlags.Sundries);
var xformQuery = GetEntityQuery<TransformComponent>();
var worldPos = _xform.GetWorldPosition(xform, xformQuery);
var physQuery = GetEntityQuery<PhysicsComponent>();

foreach (var ent in lookup)
{
if (physQuery.TryGetComponent(ent, out var phys)
&& (phys.CollisionMask & (int) CollisionGroup.GhostImpassable) != 0)
continue;

var foo = _xform.GetWorldPosition(ent, xformQuery) - worldPos;
_throwing.TryThrow(ent, foo * 10, strength, args.Performer, 0);

if (_force.TryRemoveVolume(ent, _random.Next(10, 30)))
_popup.PopupEntity("Устоял!", ent);
else
_stun.TryParalyze(ent, TimeSpan.FromSeconds(args.StunTime), true);
}

args.Handled = true;
}
private void OnFlashAreaEvent(FlashAreaEvent args)
{
if (args.Handled) return;
_flashSystem.FlashArea(args.Performer, args.Performer, args.Range, args.FlashDuration, slowTo: args.SlowTo, sound: args.Sound);
args.Handled = true;
}
private void OnDash(ForceDashActionEvent args)
{
if (args.Handled) return;
_throwing.TryThrow(args.Performer, args.Target, args.Strength);
args.Handled = true;
}
private void OnHypnosis(HypnosisTargetActionEvent args)
{
if (args.Handled || _mobState.IsIncapacitated(args.Target) || HasComp<MindShieldComponent>(args.Target)) return;
_conversion.TryConvert(args.Target, "HypnotizedEmpire", args.Performer); // FIXME: Hardcode. Исправим в обновлении инквизитора.
args.Handled = true;
}
private void OnIgnite(IgniteTargetActionEvent args)
{
if (args.Handled || _mobState.IsIncapacitated(args.Target) || HasComp<ProtectedByProtectiveBubbleComponent>(args.Target)) return; // FIXME: Hardcode

_flammable.AdjustFireStacks(args.Target, args.StackAmount);
_flammable.Ignite(args.Target, args.Performer);

args.Handled = true;
}
private void OnStrike(LightningStrikeEvent args)
{
if (args.Handled) return;
_lightning.ShootLightning(args.Performer, args.Target);
args.Handled = true;
}
private void OnFreedom(FreedomActionEvent args)
{
if (!TryComp<CuffableComponent>(args.Performer, out var cuffs) || cuffs.Container.ContainedEntities.Count < 1) return;
_cuffable.Uncuff(args.Performer, cuffs.LastAddedCuffs, cuffs.LastAddedCuffs);
args.Handled = true;
}
private void OnEmp(EmpActionEvent args)
{
if (args.Handled) return;
_emp.EmpPulse(_xform.GetMapCoordinates(args.Performer), args.Range, args.EnergyConsumption, args.DisableDuration);
args.Handled = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public override void Initialize()
InitializePolymorph();
InitializeProtectiveBubble();
InitializeLightsaber();
InitializeLightning();
// InitializeLightning();
InitializeSteal();
}
public override void Update(float frameTime)
Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/DoAfter/DoAfterArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public sealed partial class DoAfterArgs
/// The entity invoking do_after
/// </summary>
[NonSerialized]
[DataField("user", required: true)]
[DataField("user")]
public EntityUid User;

public NetEntity NetUser;

/// <summary>
/// How long does the do_after require to complete
/// </summary>
[DataField(required: true)]
[DataField]
public TimeSpan Delay;

/// <summary>
Expand Down Expand Up @@ -50,7 +50,7 @@ public sealed partial class DoAfterArgs
/// <summary>
/// The event that will get raised when the DoAfter has finished. If null, this will simply raise a <see cref="SimpleDoAfterEvent"/>
/// </summary>
[DataField(required: true)]
[DataField]
public DoAfterEvent Event = default!;

/// <summary>
Expand Down
Loading
Loading