first commit

This commit is contained in:
2026-02-09 22:03:11 +03:00
commit 2e463a4923
5 changed files with 220 additions and 0 deletions

49
txflow/interfaces.go Normal file
View File

@@ -0,0 +1,49 @@
package txflow
import "sync"
type Position struct {
X, Y, Z float64
World string
}
type World interface {
Name() string
Exec(func(Tx))
}
type Tx interface {
World() World
}
type Entity interface {
Teleport(Position)
}
type Handle interface {
Entity(tx Tx) (Entity, bool)
ExecWorld(func(tx Tx, e Entity))
}
type WorldResolver interface {
Resolve(name string) (World, error)
}
type SafeBox[T any] struct {
mu sync.RWMutex
v T
}
func (s *SafeBox[T]) Set(v T) {
s.mu.Lock()
s.v = v
s.mu.Unlock()
}
func (s *SafeBox[T]) Get() T {
s.mu.RLock()
v := s.v
s.mu.RUnlock()
return v
}