Do not allow placement of blocks within entities
This commit is contained in:
parent
e51d22cb52
commit
9a61e73ebd
@ -137,25 +137,29 @@ namespace TrueCraft.Core.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test for entities
|
// Test for entities
|
||||||
|
if (BoundingBox.HasValue)
|
||||||
|
{
|
||||||
var em = user.Server.GetEntityManagerForWorld(world);
|
var em = user.Server.GetEntityManagerForWorld(world);
|
||||||
var entities = em.EntitiesInRange(coordinates, 2);
|
var entities = em.EntitiesInRange(coordinates, 3);
|
||||||
var box = new BoundingBox(coordinates, coordinates + Vector3.One);
|
var box = new BoundingBox(BoundingBox.Value.Min + (Vector3)coordinates,
|
||||||
|
BoundingBox.Value.Max + (Vector3)coordinates);
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entities)
|
||||||
{
|
{
|
||||||
var aabb = entity as IAABBEntity;
|
var aabb = entity as IAABBEntity;
|
||||||
if (aabb != null && !(entity is ItemEntity))
|
if (aabb != null && !(entity is ItemEntity))
|
||||||
{
|
{
|
||||||
if (aabb.BoundingBox.Intersects(box) && false) // TODO: Figure out
|
if (aabb.BoundingBox.Intersects(box))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var player = entity as PlayerEntity; // Players do not implement IAABBEntity
|
var player = entity as PlayerEntity; // Players do not implement IAABBEntity
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
if (new BoundingBox(player.Position, player.Position + player.Size)
|
if (new BoundingBox(player.Position, player.Position + player.Size)
|
||||||
.Intersects(box) && false)
|
.Intersects(box))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Place block
|
// Place block
|
||||||
world.SetBlockID(coordinates, ID);
|
world.SetBlockID(coordinates, ID);
|
||||||
|
Reference in New Issue
Block a user