wip: floor texture

This commit is contained in:
2024-04-19 17:32:52 +07:00
parent bcd0650aed
commit 9affa5d845
8 changed files with 116 additions and 14 deletions

30
Entities/FloorFactory.cs Normal file
View File

@@ -0,0 +1,30 @@
using System.Numerics;
using BakeryGame.Components.Common;
using BakeryGame.Components.Environment;
using Raylib_cs;
using Scellecs.Morpeh;
namespace BakeryGame.Entities;
public class FloorFactory
{
private readonly World _world;
public FloorFactory(World world)
{
_world = world;
}
public Entity CreateFloorBlock(float x, float z, float width, float height)
{
var position = new Vector3(x, 0, z);
var size = new Vector3(width, 0, height);
var block = _world.CreateEntity();
block.SetComponent(new FloorComponent { Size = size });
block.SetComponent(new ColorComponent { Color = Color.Red });
block.SetComponent(new PositionComponent(){ Position = position });
return block;
}
}

View File

@@ -6,7 +6,7 @@ public class RoomBuilder
{
public static int RoomSize = 16;
public static IEnumerable<Entity> GenerateMapOfBlocks(BlockFactory blockFactory)
public static IEnumerable<Entity> GenerateMapOfBlocks(BlockFactory blockFactory, FloorFactory floorFactory)
{
for (int x = -RoomSize / 2; x <= RoomSize / 2; x++) {
for (int z = -RoomSize / 2; z <= RoomSize / 2; z++) {
@@ -16,5 +16,6 @@ public class RoomBuilder
}
}
}
yield return floorFactory.CreateFloorBlock(0, 0, RoomSize, RoomSize);
}
}