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