Ecsgo - Cache friendly, Multi threading Entity Component System in Go (with Generic)

ECSGo

ECSGo is an Entity Component System(ECS) in Go. This is made with Generic Go, so it needs Go 1.18 version

  • Cache friendly data storage
  • Run systems in concurrently with analyzing dependency tree.

Example

package main

import (
    "github.com/kongbong/ecsgo"
    "log"
)

type Position struct {
    X float32
    Y float32
}

type Velocity struct {
    X float32
    Y float32
}

func main() {
    registry := ecsgo.New()

    ecsgo.AddSystem1(registry, func (entity ecsgo.Entity, pos *Position) {		
        log.Println("Position system Done")
    })

    ecsgo.AddSystem1(registry, func (entity ecsgo.Entity, vel *Velocity) {
        log.Println("Velocity system Done")
    })

    ecsgo.AddSystem2(registry, func (entity ecsgo.Entity, pos *Position, vel *Velocity) {
        log.Println("Position, Velocity system")		
    })

    entity := registry.Create()
    ecsgo.SetEntityComponent2(registry, entity, &Position{10, 10}, &Velocity{10, 10})

    registry.Run()
}
Owner
Vong Kong
Game Backend Developer
Vong Kong
Similar Resources

Autoname - Friendly names generator with golang

autoname Friendly names generator inspired by moby's work. import "github.com/ci

Oct 16, 2022

a generic object pool for golang

Go Commons Pool The Go Commons Pool is a generic object pool for Golang, direct rewrite from Apache Commons Pool. Features Support custom PooledObject

Jan 5, 2023

Optimistic rollup tech, minimal and generic.

Opti Optimistic rollup tech, minimal and generic. VERY experimental, just exploratory code, question is: 1:1 EVM rollup with interactive fraud proof p

Aug 30, 2022

Generic mapStringInterface tool for extracting of data for CSV output

Generic mapStringInterface tool for extracting of data for CSV output

Nov 2, 2021

Generic slices for Go 1.8+

Slice A simple package that makes working with slices a little bit easier with the help of generics. Install go get github.com/twharmon/slice Example

Nov 1, 2022

Generic tools for go 1.18+

Gtools Generic tools for go 1.18+ FT (func tools) Provide func tools over iterators Iterators for functions like Filter, Map, Reduce, etc solve 3 main

Jan 12, 2022

Go-generic - A collection of experiments using Go Generics coming out in Go 1.18

Go Generic - experiments with Go 1.18 beta Data structures: iter.Iter[T any] - l

Aug 15, 2022

Nune - High-performance numerical engine based on generic tensors

Nune (v0.1) Numerical engine is a library for performing numerical computation i

Nov 9, 2022

Generic-list-go - Go container/list but with generics

generic-list-go Go container/list but with generics. The code is based on contai

Dec 7, 2022
Comments
  • Race condition on `Registry.setSystemDeltaSeconds`

    Race condition on `Registry.setSystemDeltaSeconds`

    Hi!

    It seems that there's a race condition in Registry.setSystemDeltaSeconds, or I might be misunderstanding something.

    This is the minimal example that reproduces the issue:

    func TestRaceCondition(t *testing.T) {
    	reg := ecsgo.New()
    	ecsgo.AddSystem(reg, ecsgo.OnTick, func(r *ecsgo.Registry) {})
    	ecsgo.AddSystem(reg, ecsgo.OnTick, func(r *ecsgo.Registry) {})
    	reg.Tick(1.0)
    }
    

    Running the snippet above with the race detector reveals the race. The goroutines launched for each of the systems end up calling setSystemDeltaSeconds(...) which write to r.sysDeltaSeconds, but there's no synchronization.

    Any suggestions? Thanks!

Related tags
Fast Entity Component System in Golang

ECS Fast Entity Component System in Golang This module is the ECS part of the game engine i'm writing in Go. Features: as fast as packages with automa

Dec 11, 2022
Packer Plugin Vagrant - The Vagrant multi-component plugin can be used with HashiCorp Packer to create custom images

Packer Plugin Vagrant - The Vagrant multi-component plugin can be used with HashiCorp Packer to create custom images

Jul 13, 2022
Go-generic-unboxing - A quick ready to ship demo for go generic using the official example

Go generic This repo contain basic demo for installing and running go1.18beta1 v

Feb 1, 2022
Generic - Golang generic example

泛型 场景 假设需要写一个列表总数计算的函数,根据不同数据类型,我们可能分别要写 SumInts(data []int),SumFloats(data []fl

Jan 27, 2022
A server for TurboRepo Remote Cache to store cache artefacts in Google Cloud Storage or Amazon S3

Tapico Turborepo Remote Cache This is an implementation of Vercel's Turborepo Remote Cache API endpoints used by the turborepo CLI command. This solut

Dec 13, 2022
A toaster component for hogosuru framework
A toaster component for hogosuru framework

Toaster component for hogosuru Toaster implementation for hogosuru How to use? Create a hogosurutoaster.Toaster or attach it to a hogosuru container a

Mar 24, 2022
A boilerplate showing how to create a Pulumi component provider written in Go

xyz Pulumi Component Provider (Go) This repo is a boilerplate showing how to create a Pulumi component provider written in Go. You can search-replace

Mar 4, 2022
The Webhooks Listener-Plugin library consists of two component libraries written in GoLang

The Webhooks Listener-Plugin library consists of two component libraries written in GoLang: WebHook Listener Libraries and Plugin (Event Consumer) Libraries.

Feb 3, 2022
Super short, fully unique, non-sequential and URL friendly Ids

Generator of unique non-sequential short Ids The package shortidenables the generation of short, fully unique, non-sequential and by default URL frien

Dec 30, 2022
A go module for "friendly" IDs

go-eyed A go module for "friendly" IDs. THIS MODULE IS INCOMPLETE AND NOT CURRENTLY BEING MAINTAINED. THEREFORE, IT SHOULD NOT BE USED Contribution If

Dec 17, 2021