2025-06-26 23:48:54 +03:00
|
|
|
package data
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.haedhutner.dev/mvv/LastMUD/internal/ecs"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ContentsComponent struct {
|
|
|
|
Contents []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cc ContentsComponent) Type() ecs.ComponentType {
|
|
|
|
return TypeContents
|
|
|
|
}
|
|
|
|
|
2025-06-27 21:36:15 +03:00
|
|
|
type CloseConnectionComponent struct{}
|
|
|
|
|
|
|
|
func (cc CloseConnectionComponent) Type() ecs.ComponentType {
|
|
|
|
return TypeCloseConnection
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateGameOutput(world *ecs.World, connectionId uuid.UUID, contents []byte, shouldClose bool) {
|
2025-06-26 23:48:54 +03:00
|
|
|
gameOutput := ecs.NewEntity()
|
|
|
|
|
|
|
|
ecs.SetComponent(world, gameOutput, ConnectionIdComponent{ConnectionId: connectionId})
|
|
|
|
ecs.SetComponent(world, gameOutput, ContentsComponent{Contents: contents})
|
2025-06-27 21:36:15 +03:00
|
|
|
|
|
|
|
if shouldClose {
|
|
|
|
ecs.SetComponent(world, gameOutput, CloseConnectionComponent{})
|
|
|
|
}
|
2025-06-26 23:48:54 +03:00
|
|
|
}
|