Physics Shapes (#306)

* Removed BoundingBoxComponent.

* Updated prototypes to use refactored CollidableComponent.

* Renamed ICollidable to IPhysBody.
Moved ICollidable to the Shared/Physics namespace.

* Migrated more yaml files to use PhysShapes.

* Updated YAML to use the new list-of-bodies system.

* Updated the new prototypes.

* Update submodule

* Update submodule again, whoops
This commit is contained in:
Acruid
2019-09-03 13:14:04 -07:00
committed by Pieter-Jan Briers
parent 5aafe89d95
commit 9353a060f2
34 changed files with 148 additions and 90 deletions

View File

@@ -5,6 +5,7 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.Chat;
using Content.Shared.Physics;
using Robust.Server.AI;
using Robust.Server.GameObjects;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
@@ -12,6 +13,7 @@ using Robust.Shared.Interfaces.Physics;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Utility;
namespace Content.Server.AI
@@ -122,8 +124,8 @@ namespace Content.Server.AI
var entWorldPos = SelfEntity.Transform.WorldPosition;
if (SelfEntity.TryGetComponent<BoundingBoxComponent>(out var bounds))
entWorldPos = bounds.WorldAABB.Center;
if (SelfEntity.TryGetComponent<CollidableComponent>(out var bounds))
entWorldPos = ((IPhysBody) bounds).WorldAABB.Center;
var rngState = GenSeed();
for (var i = 0; i < 3; i++) // you get 3 chances to find a place to walk

View File

@@ -5,8 +5,8 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Projectiles
@@ -54,7 +54,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
/// </summary>
/// <param name="collidedwith"></param>
/// <returns></returns>
bool ICollideSpecial.PreventCollide(ICollidable collidedwith)
bool ICollideSpecial.PreventCollide(IPhysBody collidedwith)
{
if (IgnoreShooter && collidedwith.Owner.Uid == Shooter)
return true;

View File

@@ -39,9 +39,9 @@ namespace Content.Server.GameObjects.Components
// after impacting the first object.
// For realism this should actually be changed when the velocity of the object is less than a threshold.
// This would allow ricochets off walls, and weird gravity effects from slowing the object.
if (collidedwith.Count > 0 && Owner.TryGetComponent(out CollidableComponent body))
if (collidedwith.Count > 0 && Owner.TryGetComponent(out CollidableComponent body) && body.PhysicsShapes.Count >= 1)
{
body.CollisionMask &= (int)~CollisionGroup.Mob;
body.PhysicsShapes[0].CollisionMask &= (int)~CollisionGroup.Mob;
body.IsScrapingFloor = true;
// KYS, your job is finished. Trigger ILand as well.

View File

@@ -329,9 +329,9 @@ namespace Content.Server.GameObjects.EntitySystems
}
// Check if ClickLocation is in object bounds here, if not lets log as warning and see why
if (attacked.TryGetComponent(out BoundingBoxComponent boundingBox))
if (attacked.TryGetComponent(out ICollidableComponent collideComp))
{
if (!boundingBox.WorldAABB.Contains(coordinates.ToWorld(_mapManager).Position))
if (!collideComp.WorldAABB.Contains(coordinates.ToWorld(_mapManager).Position))
{
Logger.WarningS("system.interaction",
$"Player {player.Name} clicked {attacked.Name} outside of its bounding box component somehow");

View File

@@ -17,6 +17,7 @@ using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Players;
namespace Content.Server.GameObjects.EntitySystems
@@ -170,7 +171,11 @@ namespace Content.Server.GameObjects.EntitySystems
if (!throwEnt.TryGetComponent(out ThrownItemComponent projComp))
{
projComp = throwEnt.AddComponent<ThrownItemComponent>();
colComp.CollisionMask |= (int)CollisionGroup.Mob;
if(colComp.PhysicsShapes.Count == 0)
colComp.PhysicsShapes.Add(new PhysShapeAabb());
colComp.PhysicsShapes[0].CollisionMask |= (int)CollisionGroup.Mob;
colComp.IsScrapingFloor = false;
}