Do not allow placement of blocks within entities

This commit is contained in:
Drew DeVault 2016-07-04 20:26:59 -04:00
parent e51d22cb52
commit 9a61e73ebd

View File

@ -137,23 +137,27 @@ namespace TrueCraft.Core.Logic
} }
// Test for entities // Test for entities
var em = user.Server.GetEntityManagerForWorld(world); if (BoundingBox.HasValue)
var entities = em.EntitiesInRange(coordinates, 2);
var box = new BoundingBox(coordinates, coordinates + Vector3.One);
foreach (var entity in entities)
{ {
var aabb = entity as IAABBEntity; var em = user.Server.GetEntityManagerForWorld(world);
if (aabb != null && !(entity is ItemEntity)) var entities = em.EntitiesInRange(coordinates, 3);
var box = new BoundingBox(BoundingBox.Value.Min + (Vector3)coordinates,
BoundingBox.Value.Max + (Vector3)coordinates);
foreach (var entity in entities)
{ {
if (aabb.BoundingBox.Intersects(box) && false) // TODO: Figure out var aabb = entity as IAABBEntity;
return; if (aabb != null && !(entity is ItemEntity))
} {
var player = entity as PlayerEntity; // Players do not implement IAABBEntity if (aabb.BoundingBox.Intersects(box))
if (player != null) return;
{ }
if (new BoundingBox(player.Position, player.Position + player.Size) var player = entity as PlayerEntity; // Players do not implement IAABBEntity
.Intersects(box) && false) if (player != null)
return; {
if (new BoundingBox(player.Position, player.Position + player.Size)
.Intersects(box))
return;
}
} }
} }