makes conveyors to use machine linking & refactors machine linking a bit (#2464)
* makes conveyors to use machine linking & refactors machine linking a bit * nullable errors * temp commit, starting work on construction * working recipies & graphs * fixes crash * makes items gravitate towards the center when on a conveyor * makes conveyors take bool signal too * ignores components clientside * default arm entitymanager maxtransmitters unsubscribe methods * twowayLEVER * _ * componentreference struct * yaml run leverDefinitelyNotCopiedFromGirderNoNoNo dies today :( * nullable * no divide by 0 * making sloth happy * space gone - happy? * final fix * yes * adds item to lathe * conveyor item -> conveyor assembly * technology * reviews ADRESSED * Update Content.Shared/GameObjects/Verbs/VerbUtility.cs Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared.Physics
|
||||
{
|
||||
@@ -10,7 +13,7 @@ namespace Content.Shared.Physics
|
||||
{
|
||||
public override IPhysicsComponent? ControlledComponent { protected get; set; }
|
||||
|
||||
public void Move(Vector2 velocityDirection, float speed)
|
||||
public void Move(Vector2 velocityDirection, float speed, Vector2 itemRelativeToConveyor)
|
||||
{
|
||||
if (ControlledComponent?.Owner.IsWeightless() ?? false)
|
||||
{
|
||||
@@ -23,6 +26,33 @@ namespace Content.Shared.Physics
|
||||
}
|
||||
|
||||
LinearVelocity = velocityDirection * speed;
|
||||
|
||||
//gravitating item towards center
|
||||
//http://csharphelper.com/blog/2016/09/find-the-shortest-distance-between-a-point-and-a-line-segment-in-c/
|
||||
Vector2 centerPoint;
|
||||
|
||||
var t = 0f;
|
||||
if (velocityDirection.Length > 0) //if velocitydirection is 0, this calculation will divide by 0
|
||||
{
|
||||
t = Vector2.Dot(itemRelativeToConveyor, velocityDirection) /
|
||||
Vector2.Dot(velocityDirection, velocityDirection);
|
||||
}
|
||||
|
||||
if (t < 0)
|
||||
{
|
||||
centerPoint = new Vector2();
|
||||
}
|
||||
else if(t > 1)
|
||||
{
|
||||
centerPoint = velocityDirection;
|
||||
}
|
||||
else
|
||||
{
|
||||
centerPoint = velocityDirection * t;
|
||||
}
|
||||
|
||||
var delta = centerPoint - itemRelativeToConveyor;
|
||||
LinearVelocity += delta * (4 * delta.Length);
|
||||
}
|
||||
|
||||
public override void UpdateAfterProcessing()
|
||||
|
||||
Reference in New Issue
Block a user