Skip to content

Major update v2.0.0! More concise names, less boilerplate, better docs.

Latest

Choose a tag to compare

@Kostayne Kostayne released this 02 Feb 17:20
· 10 commits to main since this release

Major release v2.0.0!

🧨 Breaking changes 🧨

Better system method names:

  • Renamed system.GetFrequency() to system.Frequency()
  • Renamed system.GetPriority() to system.Priority()
  • Renamed system.GetType() to system.Type()

✅ Convenience Improvements

Less boilerplate with SystemBase, no need in writing all systems methods:

type MovementSystem struct {
	core.SystemBase
}

// Main logic
func (s *MovementSystem) Process(es *core.EntityStore, dt time.Duration) {}

func MakeMovementSystem() *MovementSystem {
	return &MovementSystem{
		// Define system params here
		SystemBase: *core.MakeSystemBase("sys_movement", 0, 0),
	}
}

vs old way

type MovementSystem_EXP struct{}

func (s *MovementSystem_EXP) Type() string {
	return "sys_movement"
}

// System lifecycle
func (s *MovementSystem_EXP) Setup(es *core.EntityStore)   {}
func (s *MovementSystem_EXP) Cleanup(es *core.EntityStore) {}

func (s *MovementSystem_EXP) Priority() int   { return 0 }
func (s *MovementSystem_EXP) Frequency() uint { return 0 }

// Main logic
func (s *MovementSystem_EXP) Process(es *core.EntityStore, dt time.Duration) {}

func MakeMovementSystemEXP() *MovementSystem {
	return &MovementSystem{}
}

💉 Safety

SystemStore.Add() Now panics if you provide a system with already registered type.