Skip to content

FurkanKirat/DeepBound-Engine-Core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎮 DeepBound Engine Core

A custom data-oriented game engine framework built in C#, using Unity only as a runtime for rendering and deployment.

All core systems — ECS, physics, messaging, and serialization — are implemented from scratch, with zero dependency on Unity DOTS or MonoBehaviours.

⚠️ NOTE This repository is a portfolio showcase demonstrating engine architecture and performance engineering. Visual assets and proprietary gameplay systems are intentionally excluded.


🚀 Performance Metrics

Stress Test Results — Intel Core i7-13650HX

Scenario Entity Count FPS Details
Physics + Collision 6,000 moving 500+ Custom Spatial Hash Grid (O(n×k))
Full Rendering 2,000 visual 400+ Dynamic Mesh Batching (Chunk-based)
Frame Time Combined ~2.5ms Logic + Render Pipeline (Heavy Load)

Frame Time (Full Pipeline): ~2.0 – 2.5 ms

Architecture Highlights

  • Custom ECS: O(1) component queries via bitmask filtering (256 component types).
  • Spatial Partitioning: O(n×k) collision detection vs O(n²) brute force.
  • Zero-Allocation Messaging: Event bus using struct based messaging and ArrayPool<T>.
  • Automated Tooling: Custom-built C# Code Generation pipeline for automated binary serialization and type registries.

Stress Test Demo

2,000 entities @ 500+ FPS using spatial partitioning collision detection & rendering.


🏗️ Core Systems

1️⃣ Entity Component System (ECS)

Design Philosophy: Data-Oriented Design focused on cache locality and predictable memory access.

// Bitmask filtering (supports 256 component types)
var filter = ecsWorld
    .Filter<PositionComponent>()
    .With<VelocityComponent>();

foreach (var entity in filter) // O(1) bitmask check per entity
{
    ref var pos = ref ecsWorld.GetComponent<PositionComponent>(entity);
    ref var vel = ref ecsWorld.GetComponent<VelocityComponent>(entity);

    pos.Value += vel.Value * deltaTime; // Direct memory access, zero copy
}

Key Characteristics

  • Bitmask Queries: ~3 ns per entity vs ~50 ns dictionary lookups
  • Zero-Copy Access: ref returns eliminate struct copying
  • ID Recycling: Stack-based free list prevents fragmentation

2️⃣ Spatial Hash Grid (Physics)

Custom spatial partitioning for efficient broad-phase collision detection.

// O(1) insertion / removal
spatialGrid.Add(entityId, tilePosition);

// O(k) neighbor query (k = entities in nearby cells)
foreach (var neighbor in spatialGrid.GetEntities(cellX, cellY))
{
    if (CheckCollision(entity, neighbor))
        HandleCollision(entity, neighbor);
}

Benchmark Comparison

  • Brute Force (10k entities): 50M checks / frame → ~20 FPS
  • Spatial Grid (10k entities): ~100k checks / frame → 300+ FPS

3️⃣ Automated Serialization (Metaprogramming)

A dedicated Fluent ClassBuilder API removes boilerplate and automatically handles entity ID remapping during build-time/compile-time.

Developer-Written Code

[AutoSave]
public struct PoisonComponent
{
    public int Dps;
    public float Timer;

    [EntityReference] // Marks entity ID for auto-remapping
    public int TargetEntityId;
}

Generated Output (Simplified)

// PoisonSaver.cs (auto-generated)
public sealed class PoisonSaver : IComponentSaver<PoisonComponent>
{
    protected override void Deserialize(
        ref PoisonComponent component,
        BinaryReader reader,
        Dictionary<int, int> idMap)
    {
        component.Dps = reader.ReadInt32();
        component.Timer = reader.ReadSingle();

        int oldId = reader.ReadInt32();
        component.TargetEntityId = idMap.GetValueOrDefault(oldId, -1);
    }
}

Benefits

  • Zero manual serialization code
  • Type-safe binary I/O
  • Automatic entity reference resolution on load

4️⃣ Zero-Allocation Event Bus

High-frequency messaging without Garbage Collection pressure.

// Publishing (Pass by reference 'in' to avoid copying)
// 'EntityDamagedEvent' is a struct, not a class.
EventBus.Publish(in BlockPlacedEvent);

// Subscribing (internally uses ArrayPool<T>)
EventBus.Subscribe<BlockPlacedEvent>(OnBlockPlaced);

Performance: 0 GC allocations


🛠️ Tech Stack

Game Logic (Custom)

  • C# 9.0 (.NET Standard 2.1)
  • Custom ECS framework
  • In-house Fluent C# Code Generation API (ClassBuilder)
  • Spatial Hash Grid collision system

Rendering & Platform (Unity)

  • Unity 2021.3+ (runtime only)
  • Dynamic Mesh Batching: Custom MeshRenderer management with direct UV/Vertex modification.
  • Multi-platform builds (Windows, Linux, macOS)

Performance Techniques

  • Data-Oriented Design (DOD)
  • Structure of Arrays (SoA)
  • [MethodImpl(MethodImplOptions.AggressiveInlining)]
  • ArrayPool<T>-based object pooling

📁 Repository Structure

DeepBound-Engine-Core/
└── Sources/
    ├── Ecs/
    │   ├── EcsWorld.cs                     # Entity lifecycle & queries
    │   ├── ComponentMask.cs                # Bitmask filtering (PopCount)
    │   └── Filter.cs                       # Query API
    ├── Editor/
    │   ├── ClassBuilding/
    │   │   └── ClassBuilder.cs             # Fluent C# codegen API
    │   └── Ecs/
    │       └── ComponentSaverGenerator.cs  # [AutoSave] codegen script
    ├── Event/
    │   └── GameEventBus.cs                 # ArrayPool-backed messaging
    └── Physics/
        └── SpatialGrid.cs                  # Hash-based partitioning

🎯 Design Principles

  • Data-Oriented Design: SoA layouts for cache-friendly iteration
  • Profiler-Driven Optimization: All claims backed by benchmarks
  • Zero-Allocation Hot Paths: Pooling, stack allocations, no per-frame GC
  • Unity as a Tool, Not a Framework: Core logic is engine-agnostic

🎓 About

Furkan Kırat Computer Science @ Bilkent University

Focus Areas

  • Systems Programming & Memory Optimization
  • Data-Oriented Architecture
  • Custom Game Engine Design

This project demonstrates building a high-performance engine core from scratch, using Unity solely for rendering and deployment.

📧 furkankirat01@gmail.com

💼 linkedin.com/furkankirat


🔍 Recommended Reading Order

  1. ComponentMask.cs → Bit manipulation & PopCount
  2. EcsWorld.cs → Entity lifecycle & static type indexing
  3. SpatialGrid.cs → Hash-based collision detection
  4. ClassBuilder.cs → Fluent code generation API
  5. SaverGenerator.cs → Custom code generation pipeline

⚖️ License

Portfolio Project — engine core architecture showcase. Game content and proprietary systems excluded.

Code License: All Rights Reserved

Last updated: February 2026

About

High-performance 2D Sandbox Engine core featuring custom ECS architecture, SoA memory layout, and attribute-driven Binary Serialization. Powered by StructForge.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages