Update content vectors to numerics (#17759)
This commit is contained in:
@@ -82,7 +82,7 @@ public sealed class ClusterGrenadeSystem : EntitySystem
|
||||
thrownCount++;
|
||||
|
||||
// TODO: Suss out throw strength
|
||||
_throwingSystem.TryThrow(grenade, angle.ToVec().Normalized * component.ThrowDistance);
|
||||
_throwingSystem.TryThrow(grenade, angle.ToVec().Normalized() * component.ThrowDistance);
|
||||
|
||||
grenade.SpawnTimer(delay, () =>
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
@@ -75,7 +76,7 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood
|
||||
_matrix.R1C2 = size / 2;
|
||||
_matrix *= transform.WorldMatrix * Matrix3.Invert(spaceMatrix);
|
||||
var relativeAngle = transform.WorldRotation - spaceAngle;
|
||||
_offset = relativeAngle.RotateVec((size / 4, size / 4));
|
||||
_offset = relativeAngle.RotateVec(new Vector2(size / 4, size / 4));
|
||||
}
|
||||
|
||||
public override void InitTile(Vector2i initialTile)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
@@ -100,7 +101,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
var matrix = offsetMatrix * gridWorldMatrix * targetMatrix;
|
||||
var angle = gridWorldRotation - targetAngle;
|
||||
|
||||
var (x, y) = angle.RotateVec((tileSize / 4f, tileSize / 4f));
|
||||
var (x, y) = angle.RotateVec(new Vector2(tileSize / 4f, tileSize / 4f));
|
||||
|
||||
foreach (var (tile, dir) in edges)
|
||||
{
|
||||
@@ -166,9 +167,9 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
data.UnblockedDirections = AtmosDirection.Invalid; // all directions are blocked automatically.
|
||||
|
||||
if ((dir & NeighborFlag.Cardinal) == 0)
|
||||
data.BlockingGridEdges.Add(new(default, null, ((Vector2) tile + 0.5f) * tileSize, 0, tileSize));
|
||||
data.BlockingGridEdges.Add(new(default, null, (tile + Vector2Helpers.Half) * tileSize, 0, tileSize));
|
||||
else
|
||||
data.BlockingGridEdges.Add(new(tile, referenceGrid.Value, ((Vector2) tile + 0.5f) * tileSize, 0, tileSize));
|
||||
data.BlockingGridEdges.Add(new(tile, referenceGrid.Value, (tile + Vector2Helpers.Half) * tileSize, 0, tileSize));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +190,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
if (data.UnblockedDirections == AtmosDirection.Invalid)
|
||||
continue; // already all blocked.
|
||||
|
||||
var tileCenter = ((Vector2) tile + 0.5f) * tileSize;
|
||||
var tileCenter = (tile + new Vector2(0.5f, 0.5f)) * tileSize;
|
||||
foreach (var edge in data.BlockingGridEdges)
|
||||
{
|
||||
// if a blocking edge contains the center of the tile, block all directions
|
||||
@@ -200,19 +201,19 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
}
|
||||
|
||||
// check north
|
||||
if (edge.Box.Contains(tileCenter + (0, tileSize / 2f)))
|
||||
if (edge.Box.Contains(tileCenter + new Vector2(0, tileSize / 2f)))
|
||||
data.UnblockedDirections &= ~AtmosDirection.North;
|
||||
|
||||
// check south
|
||||
if (edge.Box.Contains(tileCenter + (0, -tileSize / 2f)))
|
||||
if (edge.Box.Contains(tileCenter + new Vector2(0, -tileSize / 2f)))
|
||||
data.UnblockedDirections &= ~AtmosDirection.South;
|
||||
|
||||
// check east
|
||||
if (edge.Box.Contains(tileCenter + (tileSize / 2f, 0)))
|
||||
if (edge.Box.Contains(tileCenter + new Vector2(tileSize / 2f, 0)))
|
||||
data.UnblockedDirections &= ~AtmosDirection.East;
|
||||
|
||||
// check west
|
||||
if (edge.Box.Contains(tileCenter + (-tileSize / 2f, 0)))
|
||||
if (edge.Box.Contains(tileCenter + new Vector2(-tileSize / 2f, 0)))
|
||||
data.UnblockedDirections &= ~AtmosDirection.West;
|
||||
}
|
||||
}
|
||||
@@ -382,7 +383,7 @@ public sealed class BlockedSpaceTile
|
||||
{
|
||||
Tile = tile;
|
||||
Grid = grid;
|
||||
Box = new(Box2.CenteredAround(center, (size, size)), angle, center);
|
||||
Box = new(Box2.CenteredAround(center, new Vector2(size, size)), angle, center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Shared.CCVar;
|
||||
@@ -305,7 +306,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
EntityQuery<TagComponent> tagQuery,
|
||||
EntityQuery<ProjectileComponent> projectileQuery)
|
||||
{
|
||||
var gridBox = Box2.FromDimensions(tile * DefaultTileSize, (DefaultTileSize, DefaultTileSize));
|
||||
var gridBox = Box2.FromDimensions(tile * DefaultTileSize, new Vector2(DefaultTileSize, DefaultTileSize));
|
||||
var worldBox = spaceMatrix.TransformBox(gridBox);
|
||||
var list = new List<TransformComponent>();
|
||||
var state = (list, processed, invSpaceMatrix, lookup.Owner, xformQuery, gridBox);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Explosion;
|
||||
using Robust.Shared.Map;
|
||||
@@ -272,7 +273,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
|
||||
// First attempt to find a grid that is relatively close to the explosion's center. Instead of looking in a
|
||||
// diameter x diameter sized box, use a smaller box with radius sized sides:
|
||||
var box = Box2.CenteredAround(epicenter.Position, (radius, radius));
|
||||
var box = Box2.CenteredAround(epicenter.Position, new Vector2(radius, radius));
|
||||
|
||||
foreach (var grid in _mapManager.FindGridsIntersecting(epicenter.MapId, box))
|
||||
{
|
||||
@@ -293,7 +294,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
// and using that for the grid look-up, we will just arbitrarily fudge the lookup size to be twice the diameter.
|
||||
|
||||
radius *= 4;
|
||||
box = Box2.CenteredAround(epicenter.Position, (radius, radius));
|
||||
box = Box2.CenteredAround(epicenter.Position, new Vector2(radius, radius));
|
||||
var mapGrids = _mapManager.FindGridsIntersecting(epicenter.MapId, box).ToList();
|
||||
var grids = mapGrids.Select(x => x.Owner).ToList();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Chat.Managers;
|
||||
@@ -344,10 +345,10 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
if (delta.EqualsApprox(Vector2.Zero))
|
||||
delta = new(0.01f, 0);
|
||||
|
||||
var distance = delta.Length;
|
||||
var distance = delta.Length();
|
||||
var effect = 5 * MathF.Pow(totalIntensity, 0.5f) * (1 - distance / range);
|
||||
if (effect > 0.01f)
|
||||
_recoilSystem.KickCamera(uid, -delta.Normalized * effect);
|
||||
_recoilSystem.KickCamera(uid, -delta.Normalized() * effect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public sealed partial class TriggerSystem
|
||||
if (Deleted(collidingUid))
|
||||
continue;
|
||||
|
||||
if (colliding.LinearVelocity.Length < trigger.TriggerSpeed)
|
||||
if (colliding.LinearVelocity.Length() < trigger.TriggerSpeed)
|
||||
continue;
|
||||
|
||||
// Trigger!
|
||||
|
||||
Reference in New Issue
Block a user