Update content vectors to numerics (#17759)
This commit is contained in:
@@ -241,7 +241,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
if (action.Range <= 0)
|
||||
return true;
|
||||
|
||||
var distance = (_transformSystem.GetWorldPosition(xform) - _transformSystem.GetWorldPosition(targetXform)).Length;
|
||||
var distance = (_transformSystem.GetWorldPosition(xform) - _transformSystem.GetWorldPosition(targetXform)).Length();
|
||||
return distance <= action.Range;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -112,7 +113,7 @@ public sealed class AnomalyComponent : Component
|
||||
/// This is more likely to trend upwards than donwards, because that's funny
|
||||
/// </remarks>
|
||||
[DataField("pulseStabilityVariation")]
|
||||
public Vector2 PulseStabilityVariation = (-0.1f, 0.15f);
|
||||
public Vector2 PulseStabilityVariation = new(-0.1f, 0.15f);
|
||||
|
||||
/// <summary>
|
||||
/// The sound played when an anomaly pulses
|
||||
@@ -219,7 +220,7 @@ public sealed class AnomalyComponent : Component
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("offset")]
|
||||
public readonly Vector2 FloatingOffset = (0, 0.15f);
|
||||
public readonly Vector2 FloatingOffset = new(0, 0.15f);
|
||||
|
||||
public readonly string AnimationKey = "anomalyfloat";
|
||||
#endregion
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.ComponentTrees;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -25,6 +26,8 @@ public sealed class AmbientSoundComponent : Component, IComponentTreeEntry<Ambie
|
||||
[DataField("range")]
|
||||
public float Range = 2f;
|
||||
|
||||
public Vector2 RangeVector => new Vector2(Range, Range);
|
||||
|
||||
/// <summary>
|
||||
/// Applies this volume to the sound being played.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Vehicle;
|
||||
using Content.Shared.Whitelist;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Buckle.Components;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Camera;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -52,7 +53,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
|
||||
{
|
||||
var recoil = entity.Item2;
|
||||
var eye = entity.Item1;
|
||||
var magnitude = recoil.CurrentKick.Length;
|
||||
var magnitude = recoil.CurrentKick.Length();
|
||||
if (magnitude <= 0.005f)
|
||||
{
|
||||
recoil.CurrentKick = Vector2.Zero;
|
||||
@@ -60,7 +61,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
|
||||
}
|
||||
else // Continually restore camera to 0.
|
||||
{
|
||||
var normalized = recoil.CurrentKick.Normalized;
|
||||
var normalized = recoil.CurrentKick.Normalized();
|
||||
recoil.LastKickTime += frameTime;
|
||||
var restoreRate = MathHelper.Lerp(RestoreRateMin, RestoreRateMax, Math.Min(1, recoil.LastKickTime / RestoreRateRamp));
|
||||
var restore = normalized * restoreRate * frameTime;
|
||||
@@ -69,7 +70,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
|
||||
|
||||
if (Math.Sign(y) != Math.Sign(recoil.CurrentKick.Y)) y = 0;
|
||||
|
||||
recoil.CurrentKick = (x, y);
|
||||
recoil.CurrentKick = new Vector2(x, y);
|
||||
|
||||
eye.Offset = recoil.BaseOffset + recoil.CurrentKick;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Chat.TypingIndicator;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Tag;
|
||||
using JetBrains.Annotations;
|
||||
@@ -28,14 +29,14 @@ namespace Content.Shared.Construction.Conditions
|
||||
var directionWithOffset = gridRotation.RotateVec(direction.ToVec());
|
||||
|
||||
// dot product will be positive if user direction and blueprint are co-directed
|
||||
var dotProd = Vector2.Dot(directionWithOffset.Normalized, userToObject.Normalized);
|
||||
var dotProd = Vector2.Dot(directionWithOffset.Normalized(), userToObject.Normalized());
|
||||
if (dotProd > 0)
|
||||
return false;
|
||||
|
||||
// now we need to check that user actually tries to build wallmount on a wall
|
||||
var physics = entManager.System<SharedPhysicsSystem>();
|
||||
var rUserToObj = new CollisionRay(userWorldPosition, userToObject.Normalized, (int) CollisionGroup.Impassable);
|
||||
var length = userToObject.Length;
|
||||
var rUserToObj = new CollisionRay(userWorldPosition, userToObject.Normalized(), (int) CollisionGroup.Impassable);
|
||||
var length = userToObject.Length();
|
||||
|
||||
var tagSystem = entManager.System<TagSystem>();
|
||||
|
||||
@@ -49,7 +50,7 @@ namespace Content.Shared.Construction.Conditions
|
||||
|
||||
// get this wall entity
|
||||
// check that we didn't try to build wallmount that facing another adjacent wall
|
||||
var rAdjWall = new CollisionRay(objWorldPosition, directionWithOffset.Normalized, (int) CollisionGroup.Impassable);
|
||||
var rAdjWall = new CollisionRay(objWorldPosition, directionWithOffset.Normalized(), (int) CollisionGroup.Impassable);
|
||||
var adjWallRaycastResults = physics.IntersectRayWithPredicate(entManager.GetComponent<TransformComponent>(user).MapID, rAdjWall, maxLength: 0.5f,
|
||||
predicate: e => e == targetWall.Value.HitEntity || !tagSystem.HasTag(e, "Wall"));
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.Map;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Shared.Coordinates
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Decals
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Content.Shared.Examine
|
||||
other.MapId == MapId.Nullspace) return false;
|
||||
|
||||
var dir = other.Position - origin.Position;
|
||||
var length = dir.Length;
|
||||
var length = dir.Length();
|
||||
|
||||
// If range specified also check it
|
||||
// TODO: This rounding check is here because the API is kinda eh
|
||||
@@ -175,7 +175,7 @@ namespace Content.Shared.Examine
|
||||
var occluderSystem = Get<OccluderSystem>();
|
||||
IoCManager.Resolve(ref entMan);
|
||||
|
||||
var ray = new Ray(origin.Position, dir.Normalized);
|
||||
var ray = new Ray(origin.Position, dir.Normalized());
|
||||
var rayResults = occluderSystem
|
||||
.IntersectRayWithPredicate(origin.MapId, ray, length, state, predicate, false).ToList();
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Follower.Components;
|
||||
using Content.Shared.Ghost;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Movement.Events;
|
||||
@@ -112,7 +113,7 @@ namespace Content.Shared.Friction
|
||||
|
||||
private void ReduceLinearVelocity(EntityUid uid, bool prediction, PhysicsComponent body, float friction, float frameTime)
|
||||
{
|
||||
var speed = body.LinearVelocity.Length;
|
||||
var speed = body.LinearVelocity.Length();
|
||||
|
||||
if (speed <= 0.0f)
|
||||
return;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -134,18 +135,18 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
private Vector2 GetFinalDropCoordinates(EntityUid user, MapCoordinates origin, MapCoordinates target)
|
||||
{
|
||||
var dropVector = target.Position - origin.Position;
|
||||
var requestedDropDistance = dropVector.Length;
|
||||
var requestedDropDistance = dropVector.Length();
|
||||
|
||||
if (dropVector.Length > SharedInteractionSystem.InteractionRange)
|
||||
if (dropVector.Length() > SharedInteractionSystem.InteractionRange)
|
||||
{
|
||||
dropVector = dropVector.Normalized * SharedInteractionSystem.InteractionRange;
|
||||
dropVector = dropVector.Normalized() * SharedInteractionSystem.InteractionRange;
|
||||
target = new MapCoordinates(origin.Position + dropVector, target.MapId);
|
||||
}
|
||||
|
||||
var dropLength = _interactionSystem.UnobstructedDistance(origin, target, predicate: e => e == user);
|
||||
|
||||
if (dropLength < requestedDropDistance)
|
||||
return origin.Position + dropVector.Normalized * dropLength;
|
||||
return origin.Position + dropVector.Normalized() * dropLength;
|
||||
return target.Position;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Item;
|
||||
@@ -111,7 +112,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
var itemPos = Transform(entity).MapPosition;
|
||||
|
||||
if (itemPos.MapId == xform.MapID
|
||||
&& (itemPos.Position - xform.MapPosition.Position).Length <= MaxAnimationRange
|
||||
&& (itemPos.Position - xform.MapPosition.Position).Length() <= MaxAnimationRange
|
||||
&& MetaData(entity).VisibilityMask == MetaData(uid).VisibilityMask) // Don't animate aghost pickups.
|
||||
{
|
||||
var initialPosition = EntityCoordinates.FromMap(coordinateEntity, itemPos, EntityManager);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Hands.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
@@ -70,7 +71,7 @@ namespace Content.Shared.Interaction
|
||||
return false;
|
||||
|
||||
var diff = coordinates - xform.MapPosition.Position;
|
||||
if (diff.LengthSquared <= 0.01f)
|
||||
if (diff.LengthSquared() <= 0.01f)
|
||||
return true;
|
||||
|
||||
var diffAngle = Angle.FromWorldVec(diff);
|
||||
|
||||
@@ -446,17 +446,17 @@ namespace Content.Shared.Interaction
|
||||
{
|
||||
var dir = other.Position - origin.Position;
|
||||
|
||||
if (dir.LengthSquared.Equals(0f))
|
||||
if (dir.LengthSquared().Equals(0f))
|
||||
return 0f;
|
||||
|
||||
predicate ??= _ => false;
|
||||
var ray = new CollisionRay(origin.Position, dir.Normalized, collisionMask);
|
||||
var rayResults = _sharedBroadphaseSystem.IntersectRayWithPredicate(origin.MapId, ray, dir.Length, predicate.Invoke, false).ToList();
|
||||
var ray = new CollisionRay(origin.Position, dir.Normalized(), collisionMask);
|
||||
var rayResults = _sharedBroadphaseSystem.IntersectRayWithPredicate(origin.MapId, ray, dir.Length(), predicate.Invoke, false).ToList();
|
||||
|
||||
if (rayResults.Count == 0)
|
||||
return dir.Length;
|
||||
return dir.Length();
|
||||
|
||||
return (rayResults[0].HitPos - origin.Position).Length;
|
||||
return (rayResults[0].HitPos - origin.Position).Length();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -496,7 +496,7 @@ namespace Content.Shared.Interaction
|
||||
return true;
|
||||
|
||||
var dir = other.Position - origin.Position;
|
||||
var length = dir.Length;
|
||||
var length = dir.Length();
|
||||
|
||||
// If range specified also check it
|
||||
if (range > 0f && length > range)
|
||||
@@ -513,7 +513,7 @@ namespace Content.Shared.Interaction
|
||||
length = MaxRaycastRange;
|
||||
}
|
||||
|
||||
var ray = new CollisionRay(origin.Position, dir.Normalized, (int) collisionMask);
|
||||
var ray = new CollisionRay(origin.Position, dir.Normalized(), (int) collisionMask);
|
||||
var rayResults = _sharedBroadphaseSystem.IntersectRayWithPredicate(origin.MapId, ray, length, predicate.Invoke, false).ToList();
|
||||
|
||||
return rayResults.Count == 0;
|
||||
@@ -623,7 +623,7 @@ namespace Content.Shared.Interaction
|
||||
{
|
||||
// We'll still do the raycast from the centres but we'll bump the range as we know they're in range.
|
||||
originPos = xformA.MapPosition;
|
||||
range = (originPos.Position - targetPos.Position).Length;
|
||||
range = (originPos.Position - targetPos.Position).Length();
|
||||
}
|
||||
}
|
||||
// No fixtures, e.g. wallmounts.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Maps;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Medical.Cryogenics;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Administration.Managers;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Input;
|
||||
@@ -113,7 +114,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
{
|
||||
var diff = content.TargetZoom - eye.Zoom;
|
||||
|
||||
if (diff.LengthSquared < 0.00001f)
|
||||
if (diff.LengthSquared() < 0.00001f)
|
||||
{
|
||||
eye.Zoom = content.TargetZoom;
|
||||
Dirty(eye);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Follower.Components;
|
||||
using Content.Shared.Input;
|
||||
@@ -475,10 +476,10 @@ namespace Content.Shared.Movement.Systems
|
||||
var vec = new Vector2(x, y);
|
||||
|
||||
// can't normalize zero length vector
|
||||
if (vec.LengthSquared > 1.0e-6)
|
||||
if (vec.LengthSquared() > 1.0e-6)
|
||||
{
|
||||
// Normalize so that diagonals aren't faster or something.
|
||||
vec = vec.Normalized;
|
||||
vec = vec.Normalized();
|
||||
}
|
||||
|
||||
return vec;
|
||||
|
||||
@@ -16,6 +16,7 @@ using Robust.Shared.Physics.Controllers;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
@@ -180,7 +181,7 @@ namespace Content.Shared.Movement.Systems
|
||||
var parentRotation = GetParentGridAngle(mover, xformQuery);
|
||||
var worldTotal = _relativeMovement ? parentRotation.RotateVec(total) : total;
|
||||
|
||||
DebugTools.Assert(MathHelper.CloseToPercent(total.Length, worldTotal.Length));
|
||||
DebugTools.Assert(MathHelper.CloseToPercent(total.Length(), worldTotal.Length()));
|
||||
|
||||
var velocity = physicsComponent.LinearVelocity;
|
||||
float friction;
|
||||
@@ -289,7 +290,7 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
private void Friction(float minimumFrictionSpeed, float frameTime, float friction, ref Vector2 velocity)
|
||||
{
|
||||
var speed = velocity.Length;
|
||||
var speed = velocity.Length();
|
||||
|
||||
if (speed < minimumFrictionSpeed)
|
||||
return;
|
||||
@@ -310,8 +311,8 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
private void Accelerate(ref Vector2 currentVelocity, in Vector2 velocity, float accel, float frameTime)
|
||||
{
|
||||
var wishDir = velocity != Vector2.Zero ? velocity.Normalized : Vector2.Zero;
|
||||
var wishSpeed = velocity.Length;
|
||||
var wishDir = velocity != Vector2.Zero ? velocity.Normalized() : Vector2.Zero;
|
||||
var wishSpeed = velocity.Length();
|
||||
|
||||
var currentSpeed = Vector2.Dot(currentVelocity, wishDir);
|
||||
var addSpeed = wishSpeed - currentSpeed;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.NPC.Events;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Shared.NPC;
|
||||
|
||||
public abstract class SharedPathfindingSystem : EntitySystem
|
||||
@@ -9,15 +11,18 @@ public abstract class SharedPathfindingSystem : EntitySystem
|
||||
public const byte SubStep = 4;
|
||||
|
||||
public const byte ChunkSize = 8;
|
||||
public static readonly Vector2 ChunkSizeVec = new(ChunkSize, ChunkSize);
|
||||
|
||||
/// <summary>
|
||||
/// We won't do points on edges so we'll offset them slightly.
|
||||
/// </summary>
|
||||
protected const float StepOffset = 1f / SubStep / 2f;
|
||||
|
||||
private static readonly Vector2 StepOffsetVec = new(StepOffset, StepOffset);
|
||||
|
||||
public Vector2 GetCoordinate(Vector2i chunk, Vector2i index)
|
||||
{
|
||||
return new Vector2(index.X, index.Y) / SubStep+ (chunk) * ChunkSize + StepOffset;
|
||||
return new Vector2(index.X, index.Y) / SubStep+ (chunk) * ChunkSizeVec + StepOffsetVec;
|
||||
}
|
||||
|
||||
public static float ManhattanDistance(Vector2i start, Vector2i end)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Parallax.Biomes.Layers;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Conveyor;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Conveyor;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -19,6 +20,9 @@ public abstract class SharedConveyorController : VirtualController
|
||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||
|
||||
protected const string ConveyorFixture = "conveyor";
|
||||
|
||||
private static readonly Vector2 _expansion = new Vector2(0.1f, 0.1f);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
UpdatesAfter.Add(typeof(SharedMoverController));
|
||||
@@ -123,7 +127,7 @@ public abstract class SharedConveyorController : VirtualController
|
||||
|
||||
private static Vector2 Convey(Vector2 direction, float speed, float frameTime, Vector2 itemRelative)
|
||||
{
|
||||
if (speed == 0 || direction.Length == 0)
|
||||
if (speed == 0 || direction.Length() == 0)
|
||||
return Vector2.Zero;
|
||||
|
||||
/*
|
||||
@@ -139,7 +143,7 @@ public abstract class SharedConveyorController : VirtualController
|
||||
var p = direction * (Vector2.Dot(itemRelative, direction) / Vector2.Dot(direction, direction));
|
||||
var r = itemRelative - p;
|
||||
|
||||
if (r.Length < 0.1)
|
||||
if (r.Length() < 0.1)
|
||||
{
|
||||
var velocity = direction * speed;
|
||||
return velocity * frameTime;
|
||||
@@ -149,7 +153,7 @@ public abstract class SharedConveyorController : VirtualController
|
||||
// Give a slight nudge in the direction of the conveyor to prevent
|
||||
// to collidable objects (e.g. crates) on the locker from getting stuck
|
||||
// pushing each other when rounding a corner.
|
||||
var velocity = (r + direction*0.2f).Normalized * speed;
|
||||
var velocity = (r + direction*0.2f).Normalized() * speed;
|
||||
return velocity * frameTime;
|
||||
}
|
||||
}
|
||||
@@ -175,7 +179,7 @@ public abstract class SharedConveyorController : VirtualController
|
||||
|
||||
// Yes there's still going to be the occasional rounding issue where it stops getting conveyed
|
||||
// When you fix the corner issue that will fix this anyway.
|
||||
var gridAABB = new Box2(entityXform.LocalPosition - 0.1f, entityXform.LocalPosition + 0.1f);
|
||||
var gridAABB = new Box2(entityXform.LocalPosition - _expansion, entityXform.LocalPosition + _expansion);
|
||||
|
||||
if (!conveyorBounds.Intersects(gridAABB))
|
||||
continue;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Shared.Procedural;
|
||||
|
||||
public sealed record DungeonRoom(HashSet<Vector2i> Tiles, Vector2 Center, Box2i Bounds, HashSet<Vector2i> Exterior)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Radiation.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.Random;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Random.Helpers
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Robust.Shared.Map;
|
||||
@@ -35,10 +36,11 @@ public sealed class RulesSystem : EntitySystem
|
||||
}
|
||||
|
||||
var worldPos = _transform.GetWorldPosition(xform);
|
||||
var gridRange = new Vector2(griddy.Range, griddy.Range);
|
||||
|
||||
foreach (var _ in _mapManager.FindGridsIntersecting(
|
||||
xform.MapID,
|
||||
new Box2(worldPos - griddy.Range, worldPos + griddy.Range)))
|
||||
new Box2(worldPos - gridRange, worldPos + gridRange)))
|
||||
{
|
||||
return !griddy.Inverted;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Store;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -65,7 +66,7 @@ public sealed class RevenantComponent : Component
|
||||
/// the second corresponds to the amount of time the entity is made solid.
|
||||
/// </summary>
|
||||
[DataField("harvestDebuffs")]
|
||||
public Vector2 HarvestDebuffs = (5, 5);
|
||||
public Vector2 HarvestDebuffs = new(5, 5);
|
||||
|
||||
/// <summary>
|
||||
/// The amount that is given to the revenant each time it's max essence is upgraded.
|
||||
@@ -89,7 +90,7 @@ public sealed class RevenantComponent : Component
|
||||
/// the second corresponds to the amount of time the entity is made solid.
|
||||
/// </summary>
|
||||
[DataField("defileDebuffs")]
|
||||
public Vector2 DefileDebuffs = (1, 4);
|
||||
public Vector2 DefileDebuffs = new(1, 4);
|
||||
|
||||
/// <summary>
|
||||
/// The radius around the user that this ability affects
|
||||
@@ -124,7 +125,7 @@ public sealed class RevenantComponent : Component
|
||||
/// the second corresponds to the amount of time the entity is made solid.
|
||||
/// </summary>
|
||||
[DataField("overloadDebuffs")]
|
||||
public Vector2 OverloadDebuffs = (3, 8);
|
||||
public Vector2 OverloadDebuffs = new(3, 8);
|
||||
|
||||
/// <summary>
|
||||
/// The radius around the user that this ability affects
|
||||
@@ -152,7 +153,7 @@ public sealed class RevenantComponent : Component
|
||||
/// the second corresponds to the amount of time the entity is made solid.
|
||||
/// </summary>
|
||||
[DataField("blightDebuffs")]
|
||||
public Vector2 BlightDebuffs = (2, 5);
|
||||
public Vector2 BlightDebuffs = new(2, 5);
|
||||
|
||||
/// <summary>
|
||||
/// The radius around the user that this ability affects
|
||||
@@ -174,7 +175,7 @@ public sealed class RevenantComponent : Component
|
||||
/// the second corresponds to the amount of time the entity is made solid.
|
||||
/// </summary>
|
||||
[DataField("malfunctionDebuffs")]
|
||||
public Vector2 MalfunctionDebuffs = (2, 8);
|
||||
public Vector2 MalfunctionDebuffs = new(2, 8);
|
||||
|
||||
/// <summary>
|
||||
/// The radius around the user that this ability affects
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
@@ -128,7 +128,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
if (!args.OurFixture.Hard ||
|
||||
!args.OtherFixture.Hard ||
|
||||
!TryComp<PhysicsComponent>(uid, out var physics) ||
|
||||
physics.LinearVelocity.Length < component.MinimumVelocity ||
|
||||
physics.LinearVelocity.Length() < component.MinimumVelocity ||
|
||||
_timing.CurTime < component.NextSound ||
|
||||
MetaData(uid).EntityPaused)
|
||||
{
|
||||
@@ -139,7 +139,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
const float MinVolume = -10f;
|
||||
const float MaxVolume = 2f;
|
||||
|
||||
var fraction = MathF.Min(1f, (physics.LinearVelocity.Length - component.MinimumVelocity) / MaxVolumeVelocity);
|
||||
var fraction = MathF.Min(1f, (physics.LinearVelocity.Length() - component.MinimumVelocity) / MaxVolumeVelocity);
|
||||
var volume = MinVolume + (MaxVolume - MinVolume) * fraction;
|
||||
component.NextSound = _timing.CurTime + EmitSoundOnCollideComponent.CollideCooldown;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
|
||||
@@ -102,7 +102,7 @@ public abstract class SharedStealthSystem : EntitySystem
|
||||
if (args.NewPosition.EntityId != args.OldPosition.EntityId)
|
||||
return;
|
||||
|
||||
var delta = component.MovementVisibilityRate * (args.NewPosition.Position - args.OldPosition.Position).Length;
|
||||
var delta = component.MovementVisibilityRate * (args.NewPosition.Position - args.OldPosition.Position).Length();
|
||||
ModifyVisibility(uid, delta);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public sealed class StepTriggerSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (otherPhysics.LinearVelocity.Length < component.RequiredTriggerSpeed
|
||||
if (otherPhysics.LinearVelocity.Length() < component.RequiredTriggerSpeed
|
||||
|| component.CurrentlySteppedOn.Contains(otherUid)
|
||||
|| otherAabb.IntersectPercentage(ourAabb) < component.IntersectRatio
|
||||
|| !CanTrigger(component.Owner, otherUid, component))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Physics;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Hands.Components;
|
||||
@@ -331,7 +332,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
}
|
||||
|
||||
//Checks to see if the opening position, if offset, is inside of a wall.
|
||||
if (component.EnteringOffset != (0, 0) && !HasComp<WallMountComponent>(target)) //if the entering position is offset
|
||||
if (component.EnteringOffset != new Vector2(0, 0) && !HasComp<WallMountComponent>(target)) //if the entering position is offset
|
||||
{
|
||||
var newCoords = new EntityCoordinates(target, component.EnteringOffset);
|
||||
if (!_interaction.InRangeUnobstructed(target, newCoords, 0, collisionMask: component.EnteringOffsetCollisionFlags))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Shared.Throwing
|
||||
{
|
||||
public sealed class BeforeThrowEvent : HandledEntityEventArgs
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Movement.Components;
|
||||
@@ -99,7 +100,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
float pushbackRatio = PushbackDefault,
|
||||
bool playSound = true)
|
||||
{
|
||||
if (strength <= 0 || direction == Vector2.Infinity || direction == Vector2.NaN || direction == Vector2.Zero)
|
||||
if (strength <= 0 || direction == Vector2Helpers.Infinity || direction == Vector2Helpers.NaN || direction == Vector2.Zero)
|
||||
return;
|
||||
|
||||
if ((physics.BodyType & (BodyType.Dynamic | BodyType.KinematicController)) == 0x0)
|
||||
@@ -123,11 +124,11 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
if (user != null)
|
||||
_interactionSystem.ThrownInteraction(user.Value, uid);
|
||||
|
||||
var impulseVector = direction.Normalized * strength * physics.Mass;
|
||||
var impulseVector = direction.Normalized() * strength * physics.Mass;
|
||||
_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);
|
||||
|
||||
// Estimate time to arrival so we can apply OnGround status and slow it much faster.
|
||||
var time = direction.Length / strength;
|
||||
var time = direction.Length() / strength;
|
||||
|
||||
if (time < FlyTime)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Database;
|
||||
@@ -34,6 +35,8 @@ public sealed class FloorTileSystem : EntitySystem
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
|
||||
private static readonly Vector2 CheckRange = new(1f, 1f);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -68,7 +71,7 @@ public sealed class FloorTileSystem : EntitySystem
|
||||
// so we're just gon with this for now.
|
||||
const bool inRange = true;
|
||||
var state = (inRange, location.EntityId);
|
||||
_mapManager.FindGridsIntersecting(map.MapId, new Box2(map.Position - 1f, map.Position + 1f), ref state,
|
||||
_mapManager.FindGridsIntersecting(map.MapId, new Box2(map.Position - CheckRange, map.Position + CheckRange), ref state,
|
||||
static (EntityUid entityUid, MapGridComponent grid, ref (bool weh, EntityUid EntityId) tuple) =>
|
||||
{
|
||||
if (tuple.EntityId == entityUid)
|
||||
@@ -89,10 +92,10 @@ public sealed class FloorTileSystem : EntitySystem
|
||||
var userPos = transformQuery.GetComponent(args.User).Coordinates.ToMapPos(EntityManager, _transform);
|
||||
var dir = userPos - map.Position;
|
||||
var canAccessCenter = false;
|
||||
if (dir.LengthSquared > 0.01)
|
||||
if (dir.LengthSquared() > 0.01)
|
||||
{
|
||||
var ray = new CollisionRay(map.Position, dir.Normalized, (int) CollisionGroup.Impassable);
|
||||
var results = _physics.IntersectRay(locationMap.MapId, ray, dir.Length, returnOnFirstHit: true);
|
||||
var ray = new CollisionRay(map.Position, dir.Normalized(), (int) CollisionGroup.Impassable);
|
||||
var results = _physics.IntersectRay(locationMap.MapId, ray, dir.Length(), returnOnFirstHit: true);
|
||||
canAccessCenter = !results.Any();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
@@ -304,11 +305,11 @@ public abstract partial class SharedVehicleSystem : EntitySystem
|
||||
|
||||
strap.BuckleOffsetUnclamped = xform.LocalRotation.Degrees switch
|
||||
{
|
||||
< 45f => (0, component.SouthOverride),
|
||||
< 45f => new(0, component.SouthOverride),
|
||||
<= 135f => component.BaseBuckleOffset,
|
||||
< 225f => (0, component.NorthOverride),
|
||||
<= 315f => (component.BaseBuckleOffset.X * -1, component.BaseBuckleOffset.Y),
|
||||
_ => (0, component.SouthOverride)
|
||||
< 225f => new(0, component.NorthOverride),
|
||||
<= 315f => new(component.BaseBuckleOffset.X * -1, component.BaseBuckleOffset.Y),
|
||||
_ => new(0, component.SouthOverride)
|
||||
};
|
||||
|
||||
if (!oldOffset.Equals(strap.BuckleOffsetUnclamped))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Weapons.Melee.Events;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.CombatMode;
|
||||
@@ -681,7 +682,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
|
||||
var userPos = TransformSystem.GetWorldPosition(userXform);
|
||||
var direction = targetMap.Position - userPos;
|
||||
var distance = Math.Min(component.Range, direction.Length);
|
||||
var distance = Math.Min(component.Range, direction.Length());
|
||||
|
||||
var damage = GetDamage(meleeUid, user, component) * GetModifier(meleeUid, user, component, false);
|
||||
var entities = ev.Entities;
|
||||
@@ -939,7 +940,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
var invMatrix = TransformSystem.GetInvWorldMatrix(userXform);
|
||||
var localPos = invMatrix.Transform(coordinates.Position);
|
||||
|
||||
if (localPos.LengthSquared <= 0f)
|
||||
if (localPos.LengthSquared() <= 0f)
|
||||
return;
|
||||
|
||||
localPos = userXform.LocalRotation.RotateVec(localPos);
|
||||
@@ -948,8 +949,8 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
const float bufferLength = 0.2f;
|
||||
var visualLength = length - bufferLength;
|
||||
|
||||
if (localPos.Length > visualLength)
|
||||
localPos = localPos.Normalized * visualLength;
|
||||
if (localPos.Length() > visualLength)
|
||||
localPos = localPos.Normalized() * visualLength;
|
||||
|
||||
DoLunge(user, angle, localPos, animation);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Weapons.Reflect;
|
||||
|
||||
namespace Content.Shared.Weapons.Ranged.Events;
|
||||
|
||||
@@ -410,7 +410,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
{
|
||||
var fromMap = fromCoordinates.ToMapPos(EntityManager, TransformSystem);
|
||||
var toMap = toCoordinates.ToMapPos(EntityManager, TransformSystem);
|
||||
var shotDirection = (toMap - fromMap).Normalized;
|
||||
var shotDirection = (toMap - fromMap).Normalized();
|
||||
|
||||
const float impulseStrength = 25.0f;
|
||||
var impulseVector = shotDirection * impulseStrength;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Database;
|
||||
|
||||
Reference in New Issue
Block a user