engine

package
v0.0.0-...-34b40e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComponentTypeMap

func ComponentTypeMap() map[string]uint64

func SaveComponent

func SaveComponent(history *[]ComponentHistory, c chan ComponentHistory, doneChan chan bool)

Types

type ActionProcessor

type ActionProcessor interface {
	Preprocess(game Game, entity EntityID, values []KeyValue)
	Process(game Game, entity EntityID, values []KeyValue)
}

type AvroSchema

type AvroSchema string

type ComponentHistory

type ComponentHistory struct {
	HistoryId     uint64
	EventSequence GameEventSequence
	EntityID      EntityID
	Component     Componenter
}

type ComponentType

type ComponentType string

type ComponentWithIdAndType

type ComponentWithIdAndType struct {
	ComponentType ComponentType
	Component     Componenter
}

type Componenter

type Componenter interface {
	GetComponentType() ComponentType
}

type Entity

type Entity struct {
	UUID EntityID
}

type EntityID

type EntityID uint64

type EntityListener

type EntityListener interface {
	// OnEntityAdded is called when an entity is added.
	// entityID is the unique identifier of the added entity.
	OnEntityAdded(entityID EntityID)

	// OnEntityRemoved is called when an entity is removed.
	// entityID is the unique identifier of the removed entity.
	OnEntityRemoved(entityID EntityID)

	// OnComponentAdded is called when a component is added to an entity.
	// entityID is the unique identifier of the entity.
	// componentTypeID is the unique identifier of the component type.
	// component is the instance of the added component.
	OnComponentAdded(entityID EntityID, componentType ComponentType, component any)

	// OnComponentRemoved is called when a component is removed from an entity.
	// entityID is the unique identifier of the entity.
	// componentTypeID is the unique identifier of the component type.
	OnComponentRemoved(entityID EntityID, componentType ComponentType)
}

EntityListener is an interface that defines methods for responding to changes in entities and their components. Implementers of this interface can handle events when entities are added or removed, and when components are added or removed from entities.

type EventListener

type EventListener interface {
	On(ev Eventer, phase EventSequencePhase, t *Timeline)
}

type EventSequencePhase

type EventSequencePhase int
const (
	OnSchedule    EventSequencePhase = 0
	OnCancel      EventSequencePhase = 1
	OnStack       EventSequencePhase = 2
	OnPop         EventSequencePhase = 3
	OnStackCancel EventSequencePhase = 4
	OnEvent       EventSequencePhase = 5
	After         EventSequencePhase = 6
)

type EventTracker

type EventTracker interface {
	GetType() TrackerType
	GetSchema() AvroSchema
	Track(seq GameEventSequence, ev Eventer, phase EventSequencePhase, gdv GameDataView, rec Recorder)
}

type EventType

type EventType string

type Eventer

type Eventer interface {
	GetType() EventType
}

type Game

type Game struct {
	UUID string

	Timeline Timeline
	// contains filtered or unexported fields
}

func (*Game) CreateEntity

func (g *Game) CreateEntity() EntityID

func (*Game) GetComponent

func (g *Game) GetComponent(entityID EntityID, componentType ComponentType) Componenter

func (*Game) GetGameUUID

func (g *Game) GetGameUUID() string

func (*Game) GetHistoryLen

func (g *Game) GetHistoryLen() int

func (*Game) GetOperator

func (g *Game) GetOperator(operator OperatorType) Operator

func (*Game) GetRuleSection

func (g *Game) GetRuleSection(section SectionType) Ruler

func (*Game) Init

func (g *Game) Init()

func (*Game) RegisterOperator

func (g *Game) RegisterOperator(operator OperatorType, op Operator)

func (*Game) RegisterRuleSection

func (g *Game) RegisterRuleSection(section SectionType, rule Rule)

func (*Game) Run

func (g *Game) Run()

func (*Game) SaveHistory

func (g *Game) SaveHistory()

func (*Game) SetComponent

func (g *Game) SetComponent(entityID EntityID, component Componenter)

func (*Game) Terminate

func (g *Game) Terminate()

type GameDataView

type GameDataView interface {
	GetGameUUID() string
	GetComponent(entityID EntityID, componentType ComponentType) Componenter
}

type GameEventSequence

type GameEventSequence uint64

type GameTime

type GameTime uint64

type InitializableRecorder

type InitializableRecorder interface {
	Init(trackertype TrackerType, schema AvroSchema)
	Record(trackertype TrackerType, entityID any)
}

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Operator

type Operator interface {
	Evaluate(OperatorNode) bool
}

type OperatorNode

type OperatorNode struct {
	Operator string `json:"operator"`
	Children []OperatorNode
}

type OperatorRegistry

type OperatorRegistry struct {
	Operators map[OperatorType]Operator
}

type OperatorType

type OperatorType string

type Recorder

type Recorder interface {
	//	Init(trackertype TrackerType, schema AvroSchema)
	Record(trackertype TrackerType, entityID any)
}

type Rule

type Rule struct {
	Name      string     `json:"name"`
	Condition any        `json:"condition"`
	Action    []KeyValue `json:"action"`
}

type RuleList

type RuleList struct {
	Sections []RuleSection `json:"sections"`
}

type RuleRegistry

type RuleRegistry struct {
	// contains filtered or unexported fields
}

func (*RuleRegistry) GetOperator

func (r *RuleRegistry) GetOperator(operator OperatorType) Operator

func (*RuleRegistry) GetRuleSection

func (r *RuleRegistry) GetRuleSection(section SectionType) Ruler

func (*RuleRegistry) RegisterOperator

func (r *RuleRegistry) RegisterOperator(operator OperatorType, op Operator)

func (*RuleRegistry) RegisterRuleSection

func (r *RuleRegistry) RegisterRuleSection(section SectionType, rule Rule)

type RuleSection

type RuleSection struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type Ruler

type Ruler interface {
	Apply(Rule) bool
}

A single rule

type SectionType

type SectionType string

type TimedEvent

type TimedEvent struct {
	StartTime GameTime
	Event     Eventer
}

type Timeline

type Timeline struct {
	CurrentSequence GameEventSequence
	CurrentTime     GameTime

	Game *Game
	// contains filtered or unexported fields
}

func (*Timeline) AddEventListener

func (t *Timeline) AddEventListener(e EventType, p EventSequencePhase, l EventListener)

func (*Timeline) AddTracker

func (t *Timeline) AddTracker(e EventType, p EventSequencePhase, l EventTracker)

func (*Timeline) PopEvent

func (t *Timeline) PopEvent() Eventer

func (*Timeline) Resolve

func (t *Timeline) Resolve()

func (*Timeline) RunNextEvent

func (t *Timeline) RunNextEvent()

func (*Timeline) ScheduleEvent

func (t *Timeline) ScheduleEvent(e Eventer, time GameTime)

func (*Timeline) SetRecorder

func (t *Timeline) SetRecorder(r InitializableRecorder)

func (*Timeline) StackEvent

func (t *Timeline) StackEvent(e Eventer)

type TimelineHistory

type TimelineHistory struct {
	EventSequence      GameEventSequence
	EventSequencePhase EventSequencePhase
	Eventer            Eventer
}

type TrackerType

type TrackerType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL