From 13626410c4d6db7fdc15ded5ee7865fcdbf0b88a Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Thu, 15 Jan 2026 22:05:38 +0100 Subject: refactor: transition to struct-of-arrays ECS architecture - Replace individual Entity structs with centralized component slices in Game struct (SoA layout). - Implement bitmask-based component lookup (CM_Position, CM_Move, etc.). - Convert logic from object-oriented Update() methods to standalone Systems (UpdateMoveSystem, UpdateGatherSystem, UpdateSpawnSystem). - Update rendering, selection, and input handling to iterate over component arrays. --- ecs/component.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'ecs/component.go') diff --git a/ecs/component.go b/ecs/component.go index 29ef967..ff22e53 100644 --- a/ecs/component.go +++ b/ecs/component.go @@ -1,10 +1,18 @@ package ecs -type Component[T any] struct { - IsEnabled bool - Value T -} +type Mask uint16 -func C[T any](t T) Component[T] { - return Component[T]{IsEnabled: true, Value: t} -} +const ( + CM_Position Mask = 1 << iota + CM_RelBounds + CM_Image + CM_Selection + CM_Move + CM_Order + CM_PatrolOrder + CM_GatherOrder + CM_ResourceGatherer + CM_ResourceSource + CM_ResourceStorage + CM_Spawn +) -- cgit v1.3