Implement falling gravel
This commit is contained in:
parent
52241a5ea3
commit
40314ddefa
14
TrueCraft.Core/Entities/FallingGravelEntity.cs
Normal file
14
TrueCraft.Core/Entities/FallingGravelEntity.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using TrueCraft.API;
|
||||
|
||||
namespace TrueCraft.Core.Entities
|
||||
{
|
||||
public class FallingGravelEntity : FallingSandEntity
|
||||
{
|
||||
public FallingGravelEntity(Vector3 position) : base(position)
|
||||
{
|
||||
}
|
||||
|
||||
public override byte EntityType { get { return 71; } }
|
||||
}
|
||||
}
|
@ -40,10 +40,15 @@ namespace TrueCraft.Core.Entities
|
||||
|
||||
public void TerrainCollision(Vector3 collisionPoint, Vector3 collisionDirection)
|
||||
{
|
||||
if (Despawned)
|
||||
return;
|
||||
if (collisionDirection == Vector3.Down)
|
||||
{
|
||||
var id = SandBlock.BlockID;
|
||||
if (EntityType == 71)
|
||||
id = GravelBlock.BlockID;
|
||||
EntityManager.DespawnEntity(this);
|
||||
World.SetBlockID((Coordinates3D)_Position, SandBlock.BlockID);
|
||||
World.SetBlockID((Coordinates3D)_Position, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,10 @@ using System;
|
||||
using TrueCraft.API.Logic;
|
||||
using TrueCraft.API;
|
||||
using TrueCraft.Core.Logic.Items;
|
||||
using TrueCraft.API.Networking;
|
||||
using TrueCraft.API.World;
|
||||
using TrueCraft.API.Server;
|
||||
using TrueCraft.Core.Entities;
|
||||
|
||||
namespace TrueCraft.Core.Logic.Blocks
|
||||
{
|
||||
@ -32,5 +36,19 @@ namespace TrueCraft.Core.Logic.Blocks
|
||||
else
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
|
||||
{
|
||||
BlockUpdate(descriptor, descriptor, user.Server, world);
|
||||
}
|
||||
|
||||
public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
|
||||
{
|
||||
if (world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down) == AirBlock.BlockID)
|
||||
{
|
||||
world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
|
||||
server.GetEntityManagerForWorld(world).SpawnEntity(new FallingGravelEntity(descriptor.Coordinates));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -309,6 +309,7 @@
|
||||
<Compile Include="Entities\FallingSandEntity.cs" />
|
||||
<Compile Include="Logic\Blocks\DoorBlock.cs" />
|
||||
<Compile Include="TerrainGen\StandardGenerator.cs" />
|
||||
<Compile Include="Entities\FallingGravelEntity.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user