Update content vectors to numerics (#17759)

This commit is contained in:
metalgearsloth
2023-07-08 14:08:32 +10:00
committed by GitHub
parent 15772478c9
commit 68480af109
383 changed files with 978 additions and 575 deletions

View File

@@ -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;