feat: refactoring && walls
This commit is contained in:
40
Systems/Rendering/BlockRenderSystem.cs
Normal file
40
Systems/Rendering/BlockRenderSystem.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using BakeryGame.Components.Common;
|
||||
using BakeryGame.Components.Environment;
|
||||
using Raylib_cs;
|
||||
using Scellecs.Morpeh;
|
||||
|
||||
namespace BakeryGame.Systems.Rendering;
|
||||
|
||||
public class BlockRenderSystem : ISystem
|
||||
{
|
||||
private Filter _filter;
|
||||
|
||||
public BlockRenderSystem(World world)
|
||||
{
|
||||
World = world;
|
||||
}
|
||||
|
||||
public World World { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAwake()
|
||||
{
|
||||
_filter = World.Filter.With<BlockComponent>().Build();
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
foreach (var item in _filter)
|
||||
{
|
||||
var size = item.GetComponent<BlockComponent>().Size;
|
||||
var positionComponent = item.GetComponent<PositionComponent>();
|
||||
var itemColorComponent = item.GetComponent<ColorComponent>();
|
||||
|
||||
// Draw enemy-box
|
||||
Raylib.DrawCube(positionComponent.Position, size.X, size.Y, size.Z, itemColorComponent.Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Systems/Rendering/HPRenderSystem.cs
Normal file
29
Systems/Rendering/HPRenderSystem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using BakeryGame.Components.Player;
|
||||
using Raylib_cs;
|
||||
using Scellecs.Morpeh;
|
||||
|
||||
namespace BakeryGame.Systems.Rendering;
|
||||
|
||||
public class HPRenderSystem : ILateSystem
|
||||
{
|
||||
private Filter _filter;
|
||||
public World World { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAwake()
|
||||
{
|
||||
_filter = World.Filter.With<HealthComponent>().Build();
|
||||
}
|
||||
|
||||
public void OnUpdate(float deltaTime)
|
||||
{
|
||||
foreach (var entity in _filter)
|
||||
{
|
||||
var healthComponent = entity.GetComponent<HealthComponent>();
|
||||
Raylib.DrawText($"HP: {healthComponent.HealthPoints}", 12, 12, 20, Color.Black);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user