bluespace love (#17315)
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
using Robust.Shared.Audio;
|
using Content.Server.Anomaly.Effects;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.Audio;
|
||||||
|
|
||||||
namespace Content.Shared.Anomaly.Effects.Components;
|
namespace Content.Server.Anomaly.Components;
|
||||||
|
|
||||||
[RegisterComponent, NetworkedComponent, Access(typeof(BluespaceAnomalySystem))]
|
[RegisterComponent, Access(typeof(BluespaceAnomalySystem))]
|
||||||
public sealed class BluespaceAnomalyComponent : Component
|
public sealed class BluespaceAnomalyComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.Anomaly.Components;
|
||||||
using Content.Shared.Anomaly.Components;
|
using Content.Shared.Anomaly.Components;
|
||||||
using Content.Shared.Anomaly.Effects.Components;
|
|
||||||
using Content.Shared.Mobs.Components;
|
using Content.Shared.Mobs.Components;
|
||||||
using Content.Shared.Teleportation.Components;
|
using Content.Shared.Teleportation.Components;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
namespace Content.Shared.Anomaly.Effects;
|
namespace Content.Server.Anomaly.Effects;
|
||||||
|
|
||||||
public sealed class BluespaceAnomalySystem : EntitySystem
|
public sealed class BluespaceAnomalySystem : EntitySystem
|
||||||
{
|
{
|
||||||
@@ -24,13 +24,12 @@ public sealed class BluespaceAnomalySystem : EntitySystem
|
|||||||
|
|
||||||
private void OnPulse(EntityUid uid, BluespaceAnomalyComponent component, ref AnomalyPulseEvent args)
|
private void OnPulse(EntityUid uid, BluespaceAnomalyComponent component, ref AnomalyPulseEvent args)
|
||||||
{
|
{
|
||||||
var xform = Transform(uid);
|
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
var xform = xformQuery.GetComponent(uid);
|
||||||
var range = component.MaxShuffleRadius * args.Severity;
|
var range = component.MaxShuffleRadius * args.Severity;
|
||||||
var allEnts = _lookup.GetComponentsInRange<MobStateComponent>(xform.Coordinates, range)
|
var allEnts = _lookup.GetComponentsInRange<MobStateComponent>(xform.Coordinates, range)
|
||||||
.Select(x => x.Owner).ToList();
|
.Select(x => x.Owner).ToList();
|
||||||
allEnts.Add(uid);
|
allEnts.Add(uid);
|
||||||
|
|
||||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
|
||||||
var coords = new List<Vector2>();
|
var coords = new List<Vector2>();
|
||||||
foreach (var ent in allEnts)
|
foreach (var ent in allEnts)
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Shared.Directions;
|
||||||
using Content.Shared.Projectiles;
|
using Content.Shared.Projectiles;
|
||||||
using Content.Shared.Pulling;
|
using Content.Shared.Pulling;
|
||||||
using Content.Shared.Pulling.Components;
|
using Content.Shared.Pulling.Components;
|
||||||
@@ -8,7 +9,6 @@ using Robust.Shared.Map;
|
|||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
using Robust.Shared.Physics.Dynamics;
|
||||||
using Robust.Shared.Physics.Events;
|
using Robust.Shared.Physics.Events;
|
||||||
using Robust.Shared.Player;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
namespace Content.Shared.Teleportation.Systems;
|
namespace Content.Shared.Teleportation.Systems;
|
||||||
@@ -20,12 +20,16 @@ public abstract class SharedPortalSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly INetManager _netMan = default!;
|
[Dependency] private readonly INetManager _netMan = default!;
|
||||||
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly SharedPullingSystem _pulling = default!;
|
[Dependency] private readonly SharedPullingSystem _pulling = default!;
|
||||||
|
|
||||||
private const string PortalFixture = "portalFixture";
|
private const string PortalFixture = "portalFixture";
|
||||||
private const string ProjectileFixture = "projectile";
|
private const string ProjectileFixture = "projectile";
|
||||||
|
|
||||||
|
private const int MaxRandomTeleportAttempts = 20;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -117,9 +121,7 @@ public abstract class SharedPortalSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// no linked entity--teleport randomly
|
// no linked entity--teleport randomly
|
||||||
var randVector = _random.NextVector2(component.MaxRandomRadius);
|
TeleportRandomly(uid, subject, component);
|
||||||
var newCoords = Transform(uid).Coordinates.Offset(randVector);
|
|
||||||
TeleportEntity(uid, subject, newCoords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEndCollide(EntityUid uid, PortalComponent component, ref EndCollideEvent args)
|
private void OnEndCollide(EntityUid uid, PortalComponent component, ref EndCollideEvent args)
|
||||||
@@ -155,12 +157,33 @@ public abstract class SharedPortalSystem : EntitySystem
|
|||||||
|
|
||||||
LogTeleport(portal, subject, Transform(subject).Coordinates, target);
|
LogTeleport(portal, subject, Transform(subject).Coordinates, target);
|
||||||
|
|
||||||
Transform(subject).Coordinates = target;
|
_transform.SetCoordinates(subject, target);
|
||||||
|
|
||||||
_audio.PlayPredicted(departureSound, portal, subject);
|
_audio.PlayPredicted(departureSound, portal, subject);
|
||||||
_audio.PlayPredicted(arrivalSound, subject, subject);
|
_audio.PlayPredicted(arrivalSound, subject, subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TeleportRandomly(EntityUid portal, EntityUid subject, PortalComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(portal, ref component))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var xform = Transform(portal);
|
||||||
|
var coords = xform.Coordinates;
|
||||||
|
var newCoords = coords.Offset(_random.NextVector2(component.MaxRandomRadius));
|
||||||
|
for (var i = 0; i < MaxRandomTeleportAttempts; i++)
|
||||||
|
{
|
||||||
|
var randVector = _random.NextVector2(component.MaxRandomRadius);
|
||||||
|
newCoords = coords.Offset(randVector);
|
||||||
|
if (!_lookup.GetEntitiesIntersecting(newCoords.ToMap(EntityManager, _transform), LookupFlags.Static).Any())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TeleportEntity(portal, subject, newCoords);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source,
|
protected virtual void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source,
|
||||||
EntityCoordinates target)
|
EntityCoordinates target)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user