Entity Component System framework for Ebiten
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
837 B

package gohan
import "log"
type Context struct {
Entity Entity
s int // System index.
c []ComponentID
w *World
// Component gets a Component of the currently handled Entity.
func (ctx *Context) Component(componentID ComponentID) interface{} {
var found bool
for _, id := range ctx.c {
if id == componentID {
found = true
if !found {
log.Panicf("illegal component access: component %d is not queried by system %d", componentID, ctx.s)
return ctx.w.Component(ctx.Entity, componentID)
// RemoveEntity removes the currently handled Entity's components, causing it
// to no longer be handled by any system. Because Gohan reuses removed EntityIDs,
// applications must also remove any internal references to the removed Entity.
func (ctx *Context) RemoveEntity() {