Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison committed Sep 26, 2024
1 parent 7b52ecd commit 8491556
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Content.Server/_White/Teleporter/ExperimentalTeleporterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ private void OnUse(EntityUid uid, ExperimentalTeleporterComponent component, Use
{
if (_charges.IsEmpty(uid)
|| !TryComp<TransformComponent>(args.User, out var xform)
|| _containerSystem.IsEntityInContainer(args.User)
&& !_containerSystem.TryRemoveFromContainer(args.User))
|| (_containerSystem.IsEntityInContainer(args.User)
&& !_containerSystem.TryRemoveFromContainer(args.User)))
return;

var oldCoords = xform.Coordinates;
var random = _random.Next(component.MinTeleportRange, component.MaxTeleportRange);
var range = _random.Next(component.MinTeleportRange, component.MaxTeleportRange);
var offset = xform.LocalRotation.ToWorldVec().Normalized();
var direction = xform.LocalRotation.GetDir().ToVec();
var newOffset = offset + direction * random;
var newOffset = offset + direction * range;

var coords = xform.Coordinates.Offset(newOffset).SnapToGrid(EntityManager);

Expand Down Expand Up @@ -75,15 +75,15 @@ private bool EmergencyTeleportation(EntityUid uid, EntityUid teleporterUid, Expe

private void Teleport(EntityUid uid, EntityUid teleporterUid, ExperimentalTeleporterComponent component, EntityCoordinates coords, EntityCoordinates oldCoords)
{
SoundAndEffects(component, coords, oldCoords);
PlaySoundAndEffects(component, coords, oldCoords);

_layingDown.LieDownInRange(uid, coords);
_transform.SetCoordinates(uid, coords);

_charges.UseCharge(teleporterUid);
}

private void SoundAndEffects(ExperimentalTeleporterComponent component, EntityCoordinates coords, EntityCoordinates oldCoords)
private void PlaySoundAndEffects(ExperimentalTeleporterComponent component, EntityCoordinates coords, EntityCoordinates oldCoords)
{
_audio.PlayPvs(component.TeleportSound, coords);
_audio.PlayPvs(component.TeleportSound, oldCoords);
Expand All @@ -105,6 +105,9 @@ private bool TryCheckWall(EntityCoordinates coords)

private Vector2 VectorRandomDirection(ExperimentalTeleporterComponent component, Vector2 offset, int length)
{
if (component.RandomRotations.Count == 0)
return Vector2.Zero;

var randomRotation = _random.Next(0, component.RandomRotations.Count);
return Angle.FromDegrees(component.RandomRotations[randomRotation]).RotateVec(offset.Normalized() * length);
}
Expand Down

0 comments on commit 8491556

Please sign in to comment.