Update content vectors to numerics (#17759)
This commit is contained in:
@@ -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"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user