universe

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: AGPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReservedAttributes = struct {
		Node struct {
			GuestUserType   ReservedAttribute
			NormalUserType  ReservedAttribute
			PortalSpaceType ReservedAttribute
			WorldTemplate   ReservedAttribute
			JWTKey          ReservedAttribute
		}
		World struct {
			Meta                ReservedAttribute
			Settings            ReservedAttribute
			TeleportDestination ReservedAttribute
		}
		Space struct {
			Name          ReservedAttribute
			Description   ReservedAttribute
			NewsFeedItems ReservedAttribute
			Events        ReservedAttribute
		}
		Kusama struct {
			User struct {
				Wallet ReservedAttribute
			}
			Challenges ReservedAttribute
		}
		User struct {
			HighFive ReservedAttribute
		}
	}{
		Node: struct {
			GuestUserType   ReservedAttribute
			NormalUserType  ReservedAttribute
			PortalSpaceType ReservedAttribute
			WorldTemplate   ReservedAttribute
			JWTKey          ReservedAttribute
		}{
			GuestUserType: ReservedAttribute{
				Name: "node_settings",
				Key:  "guest_user_type",
			},
			NormalUserType: ReservedAttribute{
				Name: "node_settings",
				Key:  "normal_user_type",
			},
			PortalSpaceType: ReservedAttribute{
				Name: "node_settings",
				Key:  "docking_hub_space_type",
			},
			WorldTemplate: ReservedAttribute{
				Name: "world_template",
			},
			JWTKey: ReservedAttribute{
				Name: "jwt_key",
				Key:  "secret",
			},
		},
		World: struct {
			Meta                ReservedAttribute
			Settings            ReservedAttribute
			TeleportDestination ReservedAttribute
		}{
			Meta: ReservedAttribute{
				Name: "world_meta",
			},
			Settings: ReservedAttribute{
				Name: "world_settings",
			},
			TeleportDestination: ReservedAttribute{
				Name: "teleport",
				Key:  "DestinationWorldID",
			},
		},
		Space: struct {
			Name          ReservedAttribute
			Description   ReservedAttribute
			NewsFeedItems ReservedAttribute
			Events        ReservedAttribute
		}{
			Name: ReservedAttribute{
				Name: "name",
				Key:  "name",
			},
			Description: ReservedAttribute{
				Name: "description",
			},
			NewsFeedItems: ReservedAttribute{
				Name: "news_feed",
				Key:  "items",
			},
			Events: ReservedAttribute{
				Name: "events",
				Key:  "",
			},
		},
		Kusama: struct {
			User struct {
				Wallet ReservedAttribute
			}
			Challenges ReservedAttribute
		}{
			User: struct {
				Wallet ReservedAttribute
			}{
				Wallet: ReservedAttribute{
					Name: "wallet",
					Key:  "wallet",
				},
			},
			Challenges: ReservedAttribute{
				Name: "challenge_store",
				Key:  "challenges",
			},
		},
		User: struct {
			HighFive ReservedAttribute
		}{
			HighFive: ReservedAttribute{
				Name: "high_five",
				Key:  "counter",
			},
		},
	}
)

Functions

func GetKusamaPluginID

func GetKusamaPluginID() uuid.UUID

func GetSystemPluginID

func GetSystemPluginID() uuid.UUID

func InitializeIDs

func InitializeIDs(systemPluginID, kusamaPluginID uuid.UUID) error

func InitializeNode

func InitializeNode(node Node)

Types

type APIRegister

type APIRegister interface {
	RegisterAPI(r *gin.Engine)
}

type Asset2d

type Asset2d interface {
	IDer
	Initializer

	GetMeta() *entry.Asset2dMeta
	SetMeta(meta *entry.Asset2dMeta, updateDB bool) error

	GetOptions() *entry.Asset2dOptions
	SetOptions(modifyFn modify.Fn[entry.Asset2dOptions], updateDB bool) (*entry.Asset2dOptions, error)

	GetEntry() *entry.Asset2d
	LoadFromEntry(entry *entry.Asset2d) error
}

type Asset3d

type Asset3d interface {
	IDer
	Initializer

	GetMeta() *entry.Asset3dMeta
	SetMeta(meta *entry.Asset3dMeta, updateDB bool) error

	GetOptions() *entry.Asset3dOptions
	SetOptions(modifyFn modify.Fn[entry.Asset3dOptions], updateDB bool) (*entry.Asset3dOptions, error)

	GetEntry() *entry.Asset3d
	LoadFromEntry(entry *entry.Asset3d) error
}

type Assets2d

type Assets2d interface {
	Initializer
	LoadSaver
	APIRegister

	CreateAsset2d(asset2dID uuid.UUID) (Asset2d, error)
	GetAsset2d(asset2dID uuid.UUID) (Asset2d, bool)
	GetAssets2d() map[uuid.UUID]Asset2d
	FilterAssets2d(predicateFn Assets2dFilterPredicateFn) map[uuid.UUID]Asset2d
	AddAsset2d(asset2d Asset2d, updateDB bool) error
	AddAssets2d(assets2d []Asset2d, updateDB bool) error
	RemoveAsset2d(asset2d Asset2d, updateDB bool) error
	RemoveAssets2d(assets2d []Asset2d, updateDB bool) error
}

type Assets2dFilterPredicateFn

type Assets2dFilterPredicateFn func(asset2dID uuid.UUID, asset2d Asset2d) bool

type Assets3d

type Assets3d interface {
	Initializer
	LoadSaver
	APIRegister

	CreateAsset3d(asset3dID uuid.UUID) (Asset3d, error)
	GetAsset3d(asset3dID uuid.UUID) (Asset3d, bool)
	GetAssets3d() map[uuid.UUID]Asset3d
	FilterAssets3d(predicateFn Assets3dFilterPredicateFn) map[uuid.UUID]Asset3d
	AddAsset3d(asset3d Asset3d, updateDB bool) error
	AddAssets3d(assets3d []Asset3d, updateDB bool) error
	RemoveAsset3d(asset3d Asset3d, updateDB bool) error
	RemoveAssets3d(assets3d []Asset3d, updateDB bool) error
	RemoveAsset3dByID(asset3dID uuid.UUID, updateDB bool) error
	RemoveAssets3dByIDs(assets3dIDs []uuid.UUID, updateDB bool) error
}

type Assets3dFilterPredicateFn

type Assets3dFilterPredicateFn func(asset3dID uuid.UUID, asset3d Asset3d) bool

type AttributeChangeType

type AttributeChangeType string
const (
	InvalidAttributeChangeType AttributeChangeType = ""
	ChangedAttributeChangeType AttributeChangeType = "attribute_changed"
	RemovedAttributeChangeType AttributeChangeType = "attribute_removed"
)

type AttributeType

type AttributeType interface {
	Initializer

	GetID() entry.AttributeTypeID
	GetName() string
	GetPluginID() uuid.UUID

	GetOptions() *entry.AttributeOptions
	SetOptions(modifyFn modify.Fn[entry.AttributeOptions], updateDB bool) (*entry.AttributeOptions, error)

	GetDescription() *string
	SetDescription(description *string, updateDB bool) error

	GetEntry() *entry.AttributeType
	LoadFromEntry(entry *entry.AttributeType) error
}

type AttributeTypes

type AttributeTypes interface {
	Initializer
	LoadSaver
	APIRegister

	CreateAttributeType(attributeTypeID entry.AttributeTypeID) (AttributeType, error)
	GetAttributeType(attributeTypeID entry.AttributeTypeID) (AttributeType, bool)
	GetAttributeTypes() map[entry.AttributeTypeID]AttributeType
	FilterAttributeTypes(predicateFn AttributeTypesFilterPredicateFn) map[entry.AttributeTypeID]AttributeType
	AddAttributeType(attributeType AttributeType, updateDB bool) error
	AddAttributeTypes(attributeTypes []AttributeType, updateDB bool) error
	RemoveAttributeType(attributeType AttributeType, updateDB bool) error
	RemoveAttributeTypes(attributeTypes []AttributeType, updateDB bool) error
}

type AttributeTypesFilterPredicateFn

type AttributeTypesFilterPredicateFn func(attributeTypeID entry.AttributeTypeID, attributeType AttributeType) bool

type Attributes

type Attributes[ID comparable] interface {
	GetPayload(attributeID ID) (*entry.AttributePayload, bool)
	GetValue(attributeID ID) (*entry.AttributeValue, bool)
	GetOptions(attributeID ID) (*entry.AttributeOptions, bool)
	GetEffectiveOptions(attributeID ID) (*entry.AttributeOptions, bool)

	Upsert(attributeID ID, modifyFn modify.Fn[entry.AttributePayload], updateDB bool) (*entry.AttributePayload, error)

	UpdateValue(attributeID ID, modifyFn modify.Fn[entry.AttributeValue], updateDB bool) (*entry.AttributeValue, error)
	UpdateOptions(attributeID ID, modifyFn modify.Fn[entry.AttributeOptions], updateDB bool) (*entry.AttributeOptions, error)

	Remove(attributeID ID, updateDB bool) (bool, error)
}

type Calendar

type Calendar interface {
	Initializer
	RunStopper

	OnAttributeUpsert(attributeID entry.AttributeID, value any)
	OnAttributeRemove(attributeID entry.AttributeID)
}

type DropCacher

type DropCacher interface {
	DropCache()
}

type Enabler

type Enabler interface {
	GetEnabled() bool
	SetEnabled(enabled bool)
}

type IDer

type IDer interface {
	GetID() uuid.UUID
}

type Initializer

type Initializer interface {
	Initialize(ctx context.Context) error
}

type LoadSaver

type LoadSaver interface {
	Loader
	Saver
}

type Loader

type Loader interface {
	Load() error
}

type Node

type Node interface {
	Space
	LoadSaver
	APIRegister
	SpaceCacher

	ToSpace() Space

	GetWorlds() Worlds
	GetAssets2d() Assets2d
	GetAssets3d() Assets3d
	GetSpaceTypes() SpaceTypes
	GetUserTypes() UserTypes
	GetAttributeTypes() AttributeTypes
	GetPlugins() Plugins

	GetNodeAttributes() NodeAttributes
	GetUserAttributes() UserAttributes
	GetUserUserAttributes() UserUserAttributes
	GetSpaceUserAttributes() SpaceUserAttributes

	AddAPIRegister(register APIRegister)

	WriteInfluxPoint(point *influxWrite.Point) error
}

func GetNode

func GetNode() Node

type NodeAttributes

type NodeAttributes interface {
	Attributes[entry.AttributeID]

	Len() int
}

type Plugin

type Plugin interface {
	IDer
	Initializer

	GetMeta() *entry.PluginMeta
	SetMeta(meta *entry.PluginMeta, updateDB bool) error

	GetOptions() *entry.PluginOptions
	SetOptions(modifyFn modify.Fn[entry.PluginOptions], updateDB bool) (*entry.PluginOptions, error)

	GetEntry() *entry.Plugin
	LoadFromEntry(entry *entry.Plugin) error
}

type Plugins

type Plugins interface {
	Initializer
	LoadSaver
	APIRegister

	CreatePlugin(pluginID uuid.UUID) (Plugin, error)
	GetPlugin(pluginID uuid.UUID) (Plugin, bool)
	GetPlugins() map[uuid.UUID]Plugin
	FilterPlugins(predicateFn PluginsFilterPredicateFn) map[uuid.UUID]Plugin
	AddPlugin(plugin Plugin, updateDB bool) error
	AddPlugins(plugins []Plugin, updateDB bool) error
	RemovePlugin(plugin Plugin, updateDB bool) error
	RemovePlugins(plugins []Plugin, updateDB bool) error
}

type PluginsFilterPredicateFn

type PluginsFilterPredicateFn func(pluginID uuid.UUID, plugin Plugin) bool

type ReservedAttribute

type ReservedAttribute struct {
	Name string
	Key  string
}

type RunStopper

type RunStopper interface {
	Runner
	Stopper
}

type Runner

type Runner interface {
	Run() error
}

type Saver

type Saver interface {
	Save() error
}

type Space

type Space interface {
	IDer
	Enabler
	Initializer
	RunStopper
	DropCacher

	GetWorld() World

	GetName() string
	SetName(name string, updateDB bool) error

	GetParent() Space
	SetParent(parent Space, updateDB bool) error

	GetOwnerID() uuid.UUID
	SetOwnerID(ownerID uuid.UUID, updateDB bool) error

	GetPosition() *cmath.SpacePosition
	GetActualPosition() *cmath.SpacePosition
	SetPosition(position *cmath.SpacePosition, updateDB bool) error
	SetActualPosition(pos cmath.SpacePosition, theta float64) error

	GetOptions() *entry.SpaceOptions
	GetEffectiveOptions() *entry.SpaceOptions
	SetOptions(modifyFn modify.Fn[entry.SpaceOptions], updateDB bool) (*entry.SpaceOptions, error)

	GetAsset2D() Asset2d
	SetAsset2D(asset2d Asset2d, updateDB bool) error

	GetAsset3D() Asset3d
	SetAsset3D(asset3d Asset3d, updateDB bool) error

	GetSpaceType() SpaceType
	SetSpaceType(spaceType SpaceType, updateDB bool) error

	GetSpaceAttributes() SpaceAttributes

	GetEntry() *entry.Space
	LoadFromEntry(entry *entry.Space, recursive bool) error

	Update(recursive bool) error
	UpdateChildrenPosition(recursive bool) error

	CreateSpace(spaceID uuid.UUID) (Space, error)
	GetSpace(spaceID uuid.UUID, recursive bool) (Space, bool)
	GetSpaces(recursive bool) map[uuid.UUID]Space
	FilterSpaces(predicateFn SpacesFilterPredicateFn, recursive bool) map[uuid.UUID]Space
	AddSpace(space Space, updateDB bool) error
	AddSpaces(spaces []Space, updateDB bool) error
	RemoveSpace(space Space, recursive, updateDB bool) (bool, error)
	RemoveSpaces(spaces []Space, recursive, updateDB bool) (bool, error)

	GetUser(userID uuid.UUID, recursive bool) (User, bool)
	GetUsers(recursive bool) map[uuid.UUID]User
	AddUser(user User, updateDB bool) error
	RemoveUser(user User, updateDB bool) error

	Send(msg *websocket.PreparedMessage, recursive bool) error

	SendSpawnMessage(sendFn func(msg *websocket.PreparedMessage) error, recursive bool)
	SendAttributes(sendFn func(*websocket.PreparedMessage), recursive bool)
	SendTextures(sendFn func(msg *websocket.PreparedMessage) error, recursive bool)

	LockUnityObject(user User, state uint32) bool
}

type SpaceAttributes

type SpaceAttributes interface {
	Attributes[entry.AttributeID]

	Len() int
}

type SpaceCacher

type SpaceCacher interface {
	GetAllSpaces() map[uuid.UUID]Space
	GetSpaceFromAllSpaces(spaceID uuid.UUID) (Space, bool)
	FilterAllSpaces(predicateFn SpacesFilterPredicateFn) map[uuid.UUID]Space
	AddSpaceToAllSpaces(space Space) error
	RemoveSpaceFromAllSpaces(space Space) (bool, error)
}

type SpaceFilterPredicateFn

type SpaceFilterPredicateFn func(spaceID uuid.UUID, space Space) bool

type SpaceType

type SpaceType interface {
	IDer
	Initializer

	GetName() string
	SetName(name string, updateDB bool) error

	GetCategoryName() string
	SetCategoryName(categoryName string, updateDB bool) error

	GetDescription() *string
	SetDescription(description *string, updateDB bool) error

	GetOptions() *entry.SpaceOptions
	SetOptions(modifyFn modify.Fn[entry.SpaceOptions], updateDB bool) (*entry.SpaceOptions, error)

	GetAsset2d() Asset2d
	SetAsset2d(asset2d Asset2d, updateDB bool) error

	GetAsset3d() Asset3d
	SetAsset3d(asset3d Asset3d, updateDB bool) error

	GetEntry() *entry.SpaceType
	LoadFromEntry(entry *entry.SpaceType) error
}

type SpaceTypes

type SpaceTypes interface {
	Initializer
	LoadSaver
	APIRegister

	CreateSpaceType(spaceTypeID uuid.UUID) (SpaceType, error)
	GetSpaceType(spaceTypeID uuid.UUID) (SpaceType, bool)
	GetSpaceTypes() map[uuid.UUID]SpaceType
	FilterSpaceTypes(predicateFn SpaceTypesFilterPredicateFn) map[uuid.UUID]SpaceType
	AddSpaceType(spaceType SpaceType, updateDB bool) error
	AddSpaceTypes(spaceTypes []SpaceType, updateDB bool) error
	RemoveSpaceType(spaceType SpaceType, updateDB bool) error
	RemoveSpaceTypes(spaceTypes []SpaceType, updateDB bool) error
}

type SpaceTypesFilterPredicateFn

type SpaceTypesFilterPredicateFn func(spaceTypeID uuid.UUID, spaceType SpaceType) bool

type SpaceUserAttributes

type SpaceUserAttributes interface {
	Attributes[entry.SpaceUserAttributeID]
}

SpaceUserAttributes ignores "updateDB" flag

type SpacesFilterPredicateFn

type SpacesFilterPredicateFn func(spaceID uuid.UUID, space Space) bool

type Stopper

type Stopper interface {
	Stop() error
}

type User

type User interface {
	IDer
	Initializer
	RunStopper

	GetWorld() World
	SetWorld(world World)

	GetSpace() Space
	SetSpace(space Space)

	GetUserType() UserType
	SetUserType(userType UserType, updateDB bool) error

	GetProfile() *entry.UserProfile

	GetPosition() cmath.Vec3
	GetRotation() cmath.Vec3
	SetPosition(position cmath.Vec3)

	GetPosBuffer() []byte

	Update() error

	GetSessionID() uuid.UUID
	SetConnection(sessionID uuid.UUID, socketConnection *websocket.Conn) error

	Send(message *websocket.PreparedMessage) error
	SendDirectly(message *websocket.PreparedMessage) error

	ReleaseSendBuffer()

	AddInfluxTags(prefix string, point *influxWrite.Point) *influxWrite.Point
}

type UserAttributes

type UserAttributes interface {
	Attributes[entry.UserAttributeID]
}

UserAttributes ignores "updateDB" flag

type UserType

type UserType interface {
	IDer
	Initializer

	GetName() string
	SetName(name string, updateDB bool) error

	GetDescription() *string
	SetDescription(description *string, updateDB bool) error

	GetOptions() *entry.UserOptions
	SetOptions(modifyFn modify.Fn[entry.UserOptions], updateDB bool) (*entry.UserOptions, error)

	GetEntry() *entry.UserType
	LoadFromEntry(entry *entry.UserType) error
}

type UserTypes

type UserTypes interface {
	Initializer
	LoadSaver
	APIRegister

	CreateUserType(userTypeID uuid.UUID) (UserType, error)
	GetUserType(userTypeID uuid.UUID) (UserType, bool)
	GetUserTypes() map[uuid.UUID]UserType
	FilterUserTypes(predicateFn UserTypesFilterPredicateFn) map[uuid.UUID]UserType
	AddUserType(spaceType UserType, updateDB bool) error
	AddUserTypes(spaceTypes []UserType, updateDB bool) error
	RemoveUserType(spaceType UserType, updateDB bool) error
	RemoveUserTypes(spaceTypes []UserType, updateDB bool) error
}

type UserTypesFilterPredicateFn

type UserTypesFilterPredicateFn func(userTypeID uuid.UUID, userType UserType) bool

type UserUserAttributes

type UserUserAttributes interface {
	Attributes[entry.UserUserAttributeID]
}

UserUserAttributes ignores "updateDB" flag

type World

type World interface {
	Space
	LoadSaver
	SpaceCacher

	ToSpace() Space

	GetSettings() *WorldSettings

	GetCalendar() Calendar

	WriteInfluxPoint(point *influxWrite.Point) error
}

type WorldSettings

type WorldSettings struct {
	Kind       string               `db:"kind" json:"kind"`
	Spaces     map[string]uuid.UUID `db:"spaces" json:"spaces"`
	Attributes map[string]uuid.UUID `db:"spaces" json:"attributes"`
	SpaceTypes map[string]uuid.UUID `db:"space_types" json:"space_types"`
	Effects    map[string]uuid.UUID `db:"effects" json:"effects"`
}

type Worlds

type Worlds interface {
	Initializer
	RunStopper
	LoadSaver
	APIRegister

	CreateWorld(worldID uuid.UUID) (World, error)
	GetWorld(worldID uuid.UUID) (World, bool)
	GetWorlds() map[uuid.UUID]World
	FilterWorlds(predicateFn WorldsFilterPredicateFn) map[uuid.UUID]World
	AddWorld(world World, updateDB bool) error
	AddWorlds(worlds []World, updateDB bool) error
	RemoveWorld(world World, updateDB bool) error
	RemoveWorlds(worlds []World, updateDB bool) error
}

type WorldsFilterPredicateFn

type WorldsFilterPredicateFn func(worldID uuid.UUID, world World) bool

Directories

Path Synopsis
api
Text chat functionality backed by getstream.io chat service.
Text chat functionality backed by getstream.io chat service.

Jump to

Keyboard shortcuts

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