engine

package
v0.2.0-preview.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package engine provides functionality for the app engine.

Index

Constants

View Source
const (
	StateStopped   = 0
	StateStarted   = 1
	StateUpdating  = 2
	StateRendering = 3
)
View Source
const (
	EventUpdate      = -1
	EventRender      = -2
	EventCloseScene  = -3
	EventMouseDown   = -4
	EventDoubleClick = -5
	EventNavigate    = -6
	EventStop        = -7
	EventKeyDown     = -8
	EventMouseUp     = -9
	EventAppHide     = -10
	EventAppShow     = -11
	EventPaste       = -12
	EventCopy        = -13
	EventMouseIn     = -14
	EventMouseOut    = -15
	EventDropFile    = -16
	EventMouseMove   = -17
	EventAppLoaded   = -18
	EventFocusGain   = -19
	EventFocusLoose  = -20
	EventMouseScroll = -21
	EventTouchDown   = -22
	EventTouchUp     = -23
	EventTouchMove   = -24
)
View Source
const (
	MessageRedraw       = 0
	MessageBuiltinEvent = 1
)
View Source
const (
	FeatureSetWindowTitle = iota
)
View Source
const MessageMaxDepth = -1
View Source
const (
	TargetFrameTime = 16
)

Variables

This section is empty.

Functions

func BindEventHandler added in v0.1.5

func BindEventHandler(eventCode int, handler EventHandler)

BindEventHandler - shortcut for (engine *AmphionEngine) BindEventHandler(code int, handler EventHandler). Binds an event handler for the specified event code. The handler will be invoked in the event loop goroutine, when the event with the specified code is raised.

func ExecuteOnFrontendThread added in v0.1.7

func ExecuteOnFrontendThread(action func())

ExecuteOnFrontendThread - shortcut for (engine *AmphionEngine) ExecuteOnFrontendThread(action func()). Executes the specified action on frontend thread.

func GetCurrentApp added in v0.2.0

func GetCurrentApp() *frontend.App

GetCurrentApp returns the current loaded app or nil if no app is loaded.

func GetFrontendContext added in v0.2.0

func GetFrontendContext() frontend.Context

GetFrontendContext returns the global application context. See frontend.Context.

func GetResourceManager added in v0.2.0

func GetResourceManager() frontend.ResourceManager

GetResourceManager returns the current resource manager.

func GetScreenSize added in v0.2.0

func GetScreenSize() a.IntVector2

GetScreenSize returns the screen size as a.IntVector2. X and Y are the width and height of the screen.

func GetScreenSize3 added in v0.2.0

func GetScreenSize3() a.IntVector3

GetScreenSize3 returns the screen size as a.IntVector3. X and Y are the width and height of the screen. Z = 1.

func GetSpecialValueFromString added in v0.2.0

func GetSpecialValueFromString(i interface{}) interface{}

GetSpecialValueFromString returns the value corresponding to the given special string.

func IsSpecialTransformValue added in v0.2.0

func IsSpecialTransformValue(x float32) bool

IsSpecialTransformValue checks if the given float32 value is special(MatchParent, WrapContent or CenterInParent).

func IsSpecialTransformVector3 added in v0.2.0

func IsSpecialTransformVector3(pos a.Vector3) bool

IsSpecialTransformVector3 checks if the given vector contains special transform values.

func IsSpecialValueString added in v0.2.0

func IsSpecialValueString(i interface{}) bool

IsSpecialValueString checks if the provided values is a string and it is a special values string, e.g. "$MatchParent".

func IsStatefulComponent

func IsStatefulComponent(component Component) bool

Checks if the given component has state. A component becomes stateful if is implements StatefulComponent interface or contains fields with state tag.

func LogDebug added in v0.1.1

func LogDebug(msg string, values ...interface{})

LogDebug is same as LogInfo, but prints only if app is in debug mode.

func LogError added in v0.1.1

func LogError(msg string, values ...interface{})

LogError prints an error to the log from the current component, formatting the msg using fmt.Sprintf.

func LogInfo added in v0.1.1

func LogInfo(msg string, values ...interface{})

LogInfo prints a message to the log from the current component, formatting the msg using fmt.Sprintf.

func LogWarning added in v0.1.1

func LogWarning(msg string, values ...interface{})

LogWarning prints a warning to the log from the current component, formatting the msg using fmt.Sprintf.

func NameOfComponent

func NameOfComponent(component interface{}) string

NameOfComponent return the name of the given component suitable for serialization.

func Navigate(path string, args a.SiMap) (err error)

Opens the scene corresponding to the specified path. Path "/" corresponds to the app's main scene. Other paths correspond to the scene path in the scene folder. For example "res/scenes/test.scene" corresponds to "/test", "res/scenes/hello/test.scene" to "/hello/test". Args can be passed, that can be later read from the scene.

func RaiseEvent added in v0.2.0

func RaiseEvent(event AmphionEvent)

RaiseEvent raises a new event to be processed in the event goroutine.

func RequestRendering added in v0.1.1

func RequestRendering()

RequestRendering - shortcut for (engine *AmphionEngine) RequestRendering().

func RequestUpdate added in v0.1.1

func RequestUpdate()

RequestUpdate - shortcut for (engine *AmphionEngine) RequestUpdate().

func RunTask added in v0.1.1

func RunTask(task Task)

RunTask - shortcut for (engine *AmphionEngine) RunTask(task Task).

func SetWindowTitle added in v0.2.0

func SetWindowTitle(title string)

SetWindowTitle updates app's window title. On web sets the tab's title.

func UnbindEventHandler added in v0.1.5

func UnbindEventHandler(eventCode int, handler EventHandler)

UnbindEventHandler - shortcut for (engine *AmphionEngine) UnbindEventHandler(code int, handler EventHandler). Unbinds the event handler for the specified event code. The handler will no longer be invoked, when the event with the specified code is raised.

Types

type AmphionEngine

type AmphionEngine struct {
	*FeaturesManager
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *AmphionEngine

GetInstance returns pointer to the engine instance.

func Initialize

func Initialize(front frontend.Frontend) *AmphionEngine

Initialize initializes a new instance of Amphion Engine and configures it to run with the specified frontend. Returns pointer to the created engine instance. The engine is a singleton, so calling Initialize more than once will have no effect.

func (*AmphionEngine) BindEventHandler

func (engine *AmphionEngine) BindEventHandler(code int, handler EventHandler)

Binds an event handler for the specified event code. The handler will be invoked in the event loop goroutine, when the event with the specified code is raised.

func (*AmphionEngine) CloseScene

func (engine *AmphionEngine) CloseScene(callback func())

Closes the currently showing scene asynchronously. It will call the provided callback function as soon as the scene was closed. If no scene is showing calls the callback function immediately.

func (*AmphionEngine) ExecuteOnFrontendThread added in v0.1.7

func (engine *AmphionEngine) ExecuteOnFrontendThread(action func())

ExecuteOnFrontendThread executes the specified action on frontend thread. Can be used to execute UI related functions from another goroutine.

func (*AmphionEngine) ForceAllViewsRedraw added in v0.2.0

func (engine *AmphionEngine) ForceAllViewsRedraw()

func (*AmphionEngine) GetAppContext added in v0.1.7

func (engine *AmphionEngine) GetAppContext() *AppContext

GetAppContext returns the current app's context.

func (*AmphionEngine) GetComponentsManager

func (engine *AmphionEngine) GetComponentsManager() *ComponentsManager

func (*AmphionEngine) GetCurrentApp

func (engine *AmphionEngine) GetCurrentApp() *frontend.App

Returns the current loaded app or nil if no app is loaded.

func (*AmphionEngine) GetCurrentScene

func (engine *AmphionEngine) GetCurrentScene() *SceneObject

Returns the currently displaying scene object.

func (*AmphionEngine) GetFeaturesManager added in v0.2.0

func (engine *AmphionEngine) GetFeaturesManager() *FeaturesManager

GetFeaturesManager returns the current FeaturesManager.

func (*AmphionEngine) GetFrontend

func (engine *AmphionEngine) GetFrontend() frontend.Frontend

Returns the current frontend.

func (*AmphionEngine) GetGlobalContext

func (engine *AmphionEngine) GetGlobalContext() frontend.Context

Returns the global application context. See frontend.Context.

func (*AmphionEngine) GetInputManager

func (engine *AmphionEngine) GetInputManager() *InputManager

Returns the current input manager.

func (*AmphionEngine) GetLogger

func (engine *AmphionEngine) GetLogger() *Logger

Returns the logger.

func (*AmphionEngine) GetMessageDispatcher

func (engine *AmphionEngine) GetMessageDispatcher() *MessageDispatcher

func (*AmphionEngine) GetName

func (engine *AmphionEngine) GetName() string

func (*AmphionEngine) GetRenderer

func (engine *AmphionEngine) GetRenderer() *rendering.ARenderer

Returns the renderer.

func (*AmphionEngine) GetResourceManager

func (engine *AmphionEngine) GetResourceManager() frontend.ResourceManager

Returns the current resource manager.

func (*AmphionEngine) GetSceneContext added in v0.1.7

func (engine *AmphionEngine) GetSceneContext() *SceneContext

GetSceneContext returns the current scene's context.

func (*AmphionEngine) GetState

func (engine *AmphionEngine) GetState() byte

Returns the current engine state.

func (*AmphionEngine) GetStateString

func (engine *AmphionEngine) GetStateString() string

Returns the current engine state as string.

func (*AmphionEngine) GetTasksRoutine

func (engine *AmphionEngine) GetTasksRoutine() *TasksRoutine

func (*AmphionEngine) IsForcedToRedraw

func (engine *AmphionEngine) IsForcedToRedraw() bool

func (*AmphionEngine) IsRenderingRequested

func (engine *AmphionEngine) IsRenderingRequested() bool

Returns whether rendering is requested for the next update cycle.

func (*AmphionEngine) IsUpdateRequested

func (engine *AmphionEngine) IsUpdateRequested() bool

Returns whether an update is requested for the next frame.

func (*AmphionEngine) LoadApp

func (engine *AmphionEngine) LoadApp()

Loads app data from well-known source and shows the main scene.

func (*AmphionEngine) LoadPrefab added in v0.1.1

func (engine *AmphionEngine) LoadPrefab(resId a.ResId) (*SceneObject, error)

Synchronously loads prefab from file.

func (*AmphionEngine) LoadScene

func (engine *AmphionEngine) LoadScene(scene a.ResId, show bool)

Loads scene from a resource file asynchronously. If show is true, after loading also shows this scene.

func (*AmphionEngine) OnMessage

func (engine *AmphionEngine) OnMessage(_ Message) bool

func (*AmphionEngine) RaiseEvent added in v0.1.7

func (engine *AmphionEngine) RaiseEvent(event AmphionEvent)

Raises a new event.

func (*AmphionEngine) RequestRendering

func (engine *AmphionEngine) RequestRendering()

Tells the engine to schedule rendering in the next update cycle. It will also request an update, if it was not requested already.

func (*AmphionEngine) RequestUpdate

func (engine *AmphionEngine) RequestUpdate()

Tells the engine to schedule an update as soon as possible.

func (*AmphionEngine) RunTask

func (engine *AmphionEngine) RunTask(task Task)

Runs the given task in the background goroutine.

func (*AmphionEngine) SetWindowTitle added in v0.1.7

func (engine *AmphionEngine) SetWindowTitle(title string)

SetWindowTitle updates app's window title. On web sets the tab's title.

func (*AmphionEngine) ShowScene

func (engine *AmphionEngine) ShowScene(scene *SceneObject) error

Shows the specified scene object. Returns an error, if the engine is not yet ready or if another scene is already showing.

func (*AmphionEngine) Start

func (engine *AmphionEngine) Start()

Starts the engine. Must be called, before any interaction with the engine.

func (*AmphionEngine) Stop

func (engine *AmphionEngine) Stop()

Closes the current scene if any, and stops the engine.

func (*AmphionEngine) SwapScenes

func (engine *AmphionEngine) SwapScenes()

Hides the current showing scene and shows the currently loaded scene (using LoadScene). The previously showing scene will be properly stopped and the deleted. So, calling SwapScenes again wont swap the two scenes back. If no scene is loaded, wont do anything.

func (*AmphionEngine) UnbindEventHandler

func (engine *AmphionEngine) UnbindEventHandler(code int, handler EventHandler)

Unbinds the event handler for the specified event code. The handler will no longer be invoked, when the event with the specified code is raised.

func (*AmphionEngine) WaitForStop

func (engine *AmphionEngine) WaitForStop()

Blocks the calling goroutine until the engine is stopped.

type AmphionEvent

type AmphionEvent struct {
	Sender interface{}
	Code   int
	Data   interface{}
}

func NewAmphionEvent

func NewAmphionEvent(from interface{}, code int, data interface{}) AmphionEvent

type AmphionObject

type AmphionObject interface {
	Object
	NamedObject
	GetId() int64
}

type AppContext added in v0.1.7

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

App context holds app specific data.

func GetAppContext added in v0.2.0

func GetAppContext() *AppContext

GetAppContext returns the current app's context.

type BoundaryComponent

type BoundaryComponent interface {
	Component
	common.Boundary
}

A component, that determines the bounding box of an object in the scene. Used for mouse interactions.

type ClipboardData added in v0.1.1

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

Experimental Holds an entry of clipboard

func NewClipboardData added in v0.1.1

func NewClipboardData(kind, mime string, str string, bytes []byte) *ClipboardData

func (*ClipboardData) GetData added in v0.1.1

func (c *ClipboardData) GetData() []byte

func (*ClipboardData) GetKind added in v0.1.1

func (c *ClipboardData) GetKind() string

func (*ClipboardData) GetMime added in v0.1.1

func (c *ClipboardData) GetMime() string

func (*ClipboardData) GetString added in v0.1.1

func (c *ClipboardData) GetString() string

type Component

type Component interface {
	NamedObject

	// This method is called only once when the component is first created.
	OnInit(ctx InitContext)

	// This method is called every time the component is being enabled.
	// If the scene object is enabled on component attachment this method will also be called.
	OnStart()

	// This method is called when the component is being disabled.
	OnStop()
}

Basic component interface. A component is a piece of functionality, that can be attached to scene objects.

func FindComponentByName added in v0.2.0

func FindComponentByName(name string) Component

FindComponentByName searches for a component with the specified name through all the current scene object tree. See SceneObject.FindComponentByName.

type ComponentContainer

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

Wrap around container interface, that can be enabled or disabled

func NewComponentContainer

func NewComponentContainer(sceneObject *SceneObject, component Component) *ComponentContainer

func (*ComponentContainer) GetComponent

func (c *ComponentContainer) GetComponent() Component

func (*ComponentContainer) IsEnabled

func (c *ComponentContainer) IsEnabled() bool

func (*ComponentContainer) SetEnabled

func (c *ComponentContainer) SetEnabled(enabled bool)

type ComponentImpl

type ComponentImpl struct {
	Engine      *AmphionEngine
	SceneObject *SceneObject
	Logger      *Logger
	// contains filtered or unexported fields
}

Default component interface implementation

func (*ComponentImpl) GetName

func (c *ComponentImpl) GetName() string

func (ComponentImpl) NameOf

func (c ComponentImpl) NameOf(outer interface{}) string

func (*ComponentImpl) OnInit

func (c *ComponentImpl) OnInit(ctx InitContext)

func (*ComponentImpl) OnStart

func (c *ComponentImpl) OnStart()

func (*ComponentImpl) OnStop

func (c *ComponentImpl) OnStop()

type ComponentsManager

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

ComponentsManager keeps track of types of components and event handlers. that are present in the application. It also allows getting and setting the state of a component.

func (*ComponentsManager) GetComponentState

func (m *ComponentsManager) GetComponentState(component Component) a.SiMap

GetComponentState retrieves component's state and returns it as string-interface map.

func (*ComponentsManager) GetEventHandler

func (m *ComponentsManager) GetEventHandler(name string) EventHandler

GetEventHandler retrieves the previously registered event handler by it's name.

func (*ComponentsManager) GetName

func (m *ComponentsManager) GetName() string

func (*ComponentsManager) MakeComponent

func (m *ComponentsManager) MakeComponent(name string) Component

MakeComponent creates an instance of a component with the specified name. Returns the new instance of component or nil if component with that name was not registered.

func (*ComponentsManager) RegisterComponentType

func (m *ComponentsManager) RegisterComponentType(component Component)

RegisterComponentType registers component, so an instance of it can be later created using MakeComponent.

func (*ComponentsManager) RegisterEventHandler

func (m *ComponentsManager) RegisterEventHandler(handler EventHandler)

RegisterEventHandler registers an event handler, so that it can be serialized and deserialized as a part of component's state.

func (*ComponentsManager) SetComponentState

func (m *ComponentsManager) SetComponentState(component Component, state a.SiMap)

SetComponentState sets the component's state from the given state map.

type ConsoleLogger

type ConsoleLogger struct{}

func (*ConsoleLogger) Log

func (logger *ConsoleLogger) Log(level LogLevel, subsystem string, message string)

type DrawingContext

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

Contains renderer

func (DrawingContext) GetRenderer

func (c DrawingContext) GetRenderer() *rendering.ARenderer

type EventBinder

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

func (*EventBinder) Bind

func (b *EventBinder) Bind(code int, handler EventHandler)

func (*EventBinder) GetHandlers

func (b *EventBinder) GetHandlers(code int) []EventHandler

func (*EventBinder) InvokeHandlers

func (b *EventBinder) InvokeHandlers(event AmphionEvent)

func (*EventBinder) Unbind

func (b *EventBinder) Unbind(code int, handler EventHandler)

type EventHandler

type EventHandler func(event AmphionEvent) bool

Function, that handles event. Returns whether to continue event propagation or not.

type FeatureCode added in v0.2.0

type FeatureCode int

type FeaturesManager added in v0.2.0

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

FeaturesManager is responsible for keeping track of what frontend features are available and invoking them. Frontend should register all features that it provides. Then those features become available and can be invoked.

func GetFeaturesManager added in v0.2.0

func GetFeaturesManager() *FeaturesManager

GetFeaturesManager returns the current FeaturesManager.

func (*FeaturesManager) InvokeFeature added in v0.2.0

func (f *FeaturesManager) InvokeFeature(code FeatureCode, data interface{}) interface{}

InvokeFeature invokes the feature with the specified FeatureCode if is available. Passes the specified data to the feature delegate and returns the result.

func (*FeaturesManager) IsFeatureAvailable added in v0.2.0

func (f *FeaturesManager) IsFeatureAvailable(code FeatureCode) bool

IsFeatureAvailable checks if feature with the specified FeatureCode is available (provided by the frontend).

func (*FeaturesManager) RegisterFeatureDelegate added in v0.2.0

func (f *FeaturesManager) RegisterFeatureDelegate(code FeatureCode, delegate frontend.FeatureDelegate)

RegisterFeatureDelegate should be called by the frontend.

type ILogger

type ILogger interface {
	Log(level LogLevel, subsystem string, message string)
}

type InitContext

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

Contains necessary objects for component initialization

func (InitContext) GetEngine

func (c InitContext) GetEngine() *AmphionEngine

func (InitContext) GetLogger

func (c InitContext) GetLogger() *Logger

func (InitContext) GetRenderer

func (c InitContext) GetRenderer() *rendering.ARenderer

func (InitContext) GetSceneObject

func (c InitContext) GetSceneObject() *SceneObject

type InputFileData added in v0.1.1

type InputFileData struct {
	Name string
	Data []byte
	Mime string
}

Represents file data returned as a result of the user selecting file or dragging it.

type InputManager added in v0.2.0

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

func GetInputManager added in v0.2.0

func GetInputManager() *InputManager

GetInputManager returns the current input manager.

func (*InputManager) GetCursorPosition added in v0.2.0

func (m *InputManager) GetCursorPosition() a.IntVector2

type KeyEvent

type KeyEvent struct {
	Key, Code string
}

type Layout

type Layout interface {
	Component
	LayoutChildren()
}

type LogLevel

type LogLevel uint
const (
	Info    LogLevel = 0
	Warning LogLevel = 1
	Error   LogLevel = 2
)

type Logger

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

func GetLoggerForPlatform

func GetLoggerForPlatform(p common.Platform) *Logger

func (*Logger) Error

func (logger *Logger) Error(subsystem NamedObject, message string)

func (*Logger) Info

func (logger *Logger) Info(subsystem NamedObject, message string)

func (*Logger) Warning

func (logger *Logger) Warning(subsystem NamedObject, message string)

type Message

type Message struct {
	Sender interface{}
	Code   byte
	Data   interface{}
}

func NewMessage

func NewMessage(sender interface{}, code byte, data interface{}) Message

func (Message) ToString

func (m Message) ToString() string

type MessageDispatcher

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

func NewMessageDispatcher

func NewMessageDispatcher(root MessageListener) *MessageDispatcher

func (*MessageDispatcher) AddListener

func (d *MessageDispatcher) AddListener(listener MessageListener, parent MessageListener)

Adds listener into the message tree

func (*MessageDispatcher) Dispatch

func (d *MessageDispatcher) Dispatch(message Message, maxDepth int)

Sends message from the root down in the message tree

func (*MessageDispatcher) DispatchDirectly

func (d *MessageDispatcher) DispatchDirectly(listener MessageListener, message Message)

func (*MessageDispatcher) DispatchDown

func (d *MessageDispatcher) DispatchDown(from MessageListener, message Message, maxDepth int)

Sends this message up in the message tree

func (*MessageDispatcher) DispatchUp

func (d *MessageDispatcher) DispatchUp(from MessageListener, message Message)

Sends specified message down in the message tree.

func (*MessageDispatcher) RemoveListener

func (d *MessageDispatcher) RemoveListener(listener MessageListener)

Removes listener from message tree. You cannot remove the root element.

type MessageListener

type MessageListener interface {
	// Receives a message and returns whether to continue message propagation or not
	OnMessage(message Message) bool
}

Interface for receiving messages from dispatcher

type MessageListenerComponent

type MessageListenerComponent interface {
	Component
	MessageListener
}

type MouseEventData added in v0.1.5

type MouseEventData struct {
	MousePosition a.IntVector2
	SceneObject   *SceneObject
}

Represents the data of mouse related event.

type NamedObject

type NamedObject interface {
	GetName() string
}

type Object

type Object interface {
	ToString() string
}

type SceneContext added in v0.1.7

type SceneContext struct {
	Args a.SiMap
	// contains filtered or unexported fields
}

This struct holds data related to a scene.

func GetSceneContext added in v0.2.0

func GetSceneContext() *SceneContext

GetSceneContext returns the current scene's context.

type SceneObject

type SceneObject struct {
	Transform Transform
	// contains filtered or unexported fields
}

An object in the scene. The scene itself is also a SceneObject.

func FindObjectByName added in v0.2.0

func FindObjectByName(name string) *SceneObject

FindObjectByName searches for an object with the specified name through all the current scene object tree. See SceneObject.FindObjectByName.

func GerCurrentScene

func GerCurrentScene() *SceneObject

GerCurrentScene returns the currently displaying scene object.

func LoadPrefab added in v0.1.1

func LoadPrefab(resId a.ResId) (*SceneObject, error)

LoadPrefab - shortcut for (engine *AmphionEngine) LoadPrefab(resId int) (*SceneObject, error).

func NewSceneObject

func NewSceneObject(name string) *SceneObject

NewSceneObject creates a new instance of scene object. Can be used only with engine running.

func NewSceneObjectForTesting added in v0.2.0

func NewSceneObjectForTesting(name string, components ...Component) *SceneObject

NewSceneObjectForTesting creates a new instance of scene object without engine running. Can be used for testing purposes. Do not use in actual Amphion apps!

func (*SceneObject) AddChild

func (o *SceneObject) AddChild(object *SceneObject)

Adds a child object to this scene object.

func (*SceneObject) AddComponent

func (o *SceneObject) AddComponent(component Component)

Adds a component to this scene object.

func (*SceneObject) DebugString added in v0.1.12

func (o *SceneObject) DebugString() string

For GoLand debugging.

func (*SceneObject) DecodeFromYaml

func (o *SceneObject) DecodeFromYaml(data []byte) error

func (*SceneObject) EncodeToYaml

func (o *SceneObject) EncodeToYaml() ([]byte, error)

func (*SceneObject) FindComponentByName added in v0.2.0

func (o *SceneObject) FindComponentByName(name string) Component

FindComponentByName searches for a component with the specified name through all the scene object tree. Returns the first suitable component. Returns nil if no component with the name was found.

func (*SceneObject) FindObjectByName added in v0.2.0

func (o *SceneObject) FindObjectByName(name string) *SceneObject

FindObjectByName searches for an object with the specified name through all the scene object tree. Returns the first suitable object. Returns nil if no object with the name was found.

func (*SceneObject) ForEachChild added in v0.2.0

func (o *SceneObject) ForEachChild(action func(object *SceneObject))

ForEachChild cycles through all direct children of the scene object, calling the specified action for each of them. The method skips uninitialized or disabled objects.

func (*SceneObject) ForEachComponent

func (o *SceneObject) ForEachComponent(action func(component Component))

ForEachComponent iterates over each component attached to the object, calling the action function for each of them. The method skips uninitialized or disabled components.

func (*SceneObject) ForEachObject

func (o *SceneObject) ForEachObject(action func(object *SceneObject))

ForEachObject traverses the scene object tree, calling the action function for each of the objects. The action is also called for the object on which the method was called. The method skips uninitialized or disabled objects.

func (*SceneObject) FromMap

func (o *SceneObject) FromMap(siMap a.SiMap)

func (*SceneObject) GetChildByName

func (o *SceneObject) GetChildByName(name string) *SceneObject

Finds scene object in the list of children of the current object. Returns nil if no object with the specified name was not found.

func (*SceneObject) GetChildren

func (o *SceneObject) GetChildren() []*SceneObject

Returns the list of children of this object.

func (*SceneObject) GetComponentByName

func (o *SceneObject) GetComponentByName(n string) Component

GetComponentByName searches for component with the specified name throughout the components attached to this object. The parameter n can be on of the following:

- full component name, e.g. github.com/cadmean-ru/amphion/engine/builtin.TextView,

- short component name, e.g. TextView,

- regex string.

If there are multiple components with the same name returns the first. Returns nil if no component with the name n was found.

func (*SceneObject) GetComponents

func (o *SceneObject) GetComponents() []Component

Returns a slice of all components attached to the object.

func (*SceneObject) GetComponentsByName

func (o *SceneObject) GetComponentsByName(n string) []Component

GetComponentsByName searches for all components with the specified name throughout the components attached to this object. The parameter n can be on of the following:

- full component name, e.g. github.com/cadmean-ru/amphion/engine/builtin.TextView,

- short component name, e.g. TextView,

- regex string.

Returns empty slice if no components with the name n was found.

func (*SceneObject) GetId

func (o *SceneObject) GetId() int

GetId returns the id of the object in the scene. The id is not guaranteed to remain the same over time and serves for internal engine purposes. For identification use object's name.

func (*SceneObject) GetName

func (o *SceneObject) GetName() string

GetName returns the name of the scene object.

func (*SceneObject) GetParent

func (o *SceneObject) GetParent() *SceneObject

Returns the parent object of this scene object. Returns nil if no parent object.

func (*SceneObject) HasBoundary

func (o *SceneObject) HasBoundary() bool

HasBoundary checks if the scene object has any boundary components.

func (*SceneObject) IsEnabled

func (o *SceneObject) IsEnabled() bool

Returns if this object is currently enabled or not.

func (*SceneObject) IsFocused

func (o *SceneObject) IsFocused() bool

IsFocused checks if the scene object is currently focused.

func (*SceneObject) IsHovered added in v0.1.7

func (o *SceneObject) IsHovered() bool

IsHovered checks if the cursor is over the scene object.

func (*SceneObject) IsPointInsideBoundaries

func (o *SceneObject) IsPointInsideBoundaries(point a.Vector3) bool

func (*SceneObject) IsPointInsideBoundaries2D

func (o *SceneObject) IsPointInsideBoundaries2D(point a.Vector3) bool

func (*SceneObject) IsRendering

func (o *SceneObject) IsRendering() bool

IsRendering checks if the scene object has any view components.

func (*SceneObject) IsVisibleInScene added in v0.1.7

func (o *SceneObject) IsVisibleInScene() bool

func (*SceneObject) OnMessage

func (o *SceneObject) OnMessage(message Message) bool

func (*SceneObject) Redraw added in v0.1.3

func (o *SceneObject) Redraw()

Forces all views of this object to redraw and requests rendering.

func (*SceneObject) RemoveChild

func (o *SceneObject) RemoveChild(object *SceneObject)

Removes a child from this scene object.

func (*SceneObject) SetEnabled

func (o *SceneObject) SetEnabled(enabled bool)

Set the enabled state of this object as specified.

func (*SceneObject) SetPosition added in v0.1.1

func (o *SceneObject) SetPosition(v a.Vector3)

Set the position of this object equal to the specified vector, requesting rendering.

func (*SceneObject) SetPositionXy added in v0.1.3

func (o *SceneObject) SetPositionXy(x, y float32)

func (*SceneObject) SetPositionXyz added in v0.1.1

func (o *SceneObject) SetPositionXyz(x, y, z float32)

Set the position of this object equal to a new vector with specified coordinates, requesting rendering.

func (*SceneObject) SetSize added in v0.1.1

func (o *SceneObject) SetSize(v a.Vector3)

Set the size of this object equal to the specified vector, requesting rendering.

func (*SceneObject) SetSizeXy added in v0.1.7

func (o *SceneObject) SetSizeXy(x, y float32)

Set the size of this object equal to a new vector with specified coordinates, requesting rendering.

func (*SceneObject) SetSizeXyz added in v0.1.1

func (o *SceneObject) SetSizeXyz(x, y, z float32)

Set the size of this object equal to a new vector with specified coordinates, requesting rendering.

func (*SceneObject) ToMap

func (o *SceneObject) ToMap() a.SiMap

func (*SceneObject) ToString

func (o *SceneObject) ToString() string

Returns the string representation of the scene object.

func (*SceneObject) Traverse added in v0.2.0

func (o *SceneObject) Traverse(action func(object *SceneObject) bool)

Traverse traverses the scene object tree, calling the action function for each of the objects. If action returns false interrupts the process. The method skips uninitialized or disabled objects.

type StatefulComponent

type StatefulComponent interface {
	GetInstanceState() a.SiMap
	SetInstanceState(state a.SiMap)
}

Interface for components, that can persist state.

type Task

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

func NewTask

func NewTask(runner TaskRunner, callback TaskCallback, errorCallback TaskErrorCallback) Task

type TaskBuilder

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

func NewTaskBuilder

func NewTaskBuilder() *TaskBuilder

func (*TaskBuilder) Build

func (b *TaskBuilder) Build() Task

func (*TaskBuilder) Err

func (b *TaskBuilder) Err(callback TaskErrorCallback) *TaskBuilder

func (*TaskBuilder) Run

func (b *TaskBuilder) Run(runner TaskRunner) *TaskBuilder

func (*TaskBuilder) Then added in v0.1.1

func (b *TaskBuilder) Then(callback TaskCallback) *TaskBuilder

type TaskCallback

type TaskCallback func(res interface{})

type TaskErrorCallback

type TaskErrorCallback func(err error)

type TaskRunner

type TaskRunner func() (interface{}, error)

type TasksRoutine

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

func (*TasksRoutine) RunTask

func (r *TasksRoutine) RunTask(task Task)

type Transform

type Transform struct {
	Position a.Vector3
	Pivot    a.Vector3
	Rotation a.Vector3
	Size     a.Vector3

	SceneObject *SceneObject
	// contains filtered or unexported fields
}

Transform describes how a scene object is positioned on the screen.

func NewTransform

func NewTransform(object *SceneObject) Transform

Creates a new transform with default values.

func NewTransformFromMap

func NewTransformFromMap(siMap a.SiMap) Transform

func (*Transform) FromMap

func (t *Transform) FromMap(siMap a.SiMap)

func (Transform) GetGlobalPosition

func (t Transform) GetGlobalPosition() a.Vector3

Calculates the actual global position in the scene.

func (Transform) GetGlobalRect

func (t Transform) GetGlobalRect() *common.RectBoundary

Calculates global rect of this transform.

func (Transform) GetGlobalTopLeftPosition

func (t Transform) GetGlobalTopLeftPosition() a.Vector3

Calculates global position of the top left point of the bounding box.

func (Transform) GetLocalPosition

func (t Transform) GetLocalPosition() a.Vector3

Calculates the actual local position related to this transform's parent.

func (Transform) GetParent

func (t Transform) GetParent() *Transform

Returns the parent transform of the current transform.

func (Transform) GetRect

func (t Transform) GetRect() *common.RectBoundary

Calculates local rect of this transform.

func (Transform) GetSize added in v0.1.1

func (t Transform) GetSize() a.Vector3

Calculates the actual size of the Transform replacing the special values.

func (Transform) GetTopLeftPosition

func (t Transform) GetTopLeftPosition() a.Vector3

Calculates local position of the top left point of the bounding box.

func (Transform) ToMap

func (t Transform) ToMap() a.SiMap

func (*Transform) ToRenderingTransform added in v0.1.1

func (t *Transform) ToRenderingTransform() rendering.Transform

Calculates a transform that is ready to be rendered on screen with all absolute values in pixels calculated.

type UpdateContext

type UpdateContext struct {
	DeltaTime float32
}

Contains info about current update cycle

type UpdatingComponent

type UpdatingComponent interface {
	Component
	OnUpdate(ctx UpdateContext)
}

Interface for components that can receive updates.

type ViewComponent

type ViewComponent interface {
	Component
	OnDraw(ctx DrawingContext)
	ForceRedraw()
}

Interface for views.

type ViewImpl added in v0.1.1

type ViewImpl struct {
	Redraw      bool
	Context     InitContext
	PrimitiveId int
	Engine      *AmphionEngine
	SceneObject *SceneObject
}

Basic view component implementation.

func (*ViewImpl) ForceRedraw added in v0.1.1

func (v *ViewImpl) ForceRedraw()

func (*ViewImpl) GetName added in v0.1.1

func (v *ViewImpl) GetName() string

func (*ViewImpl) OnDraw added in v0.1.1

func (v *ViewImpl) OnDraw(_ DrawingContext)

func (*ViewImpl) OnInit added in v0.1.1

func (v *ViewImpl) OnInit(ctx InitContext)

func (*ViewImpl) OnMessage added in v0.1.1

func (v *ViewImpl) OnMessage(message Message) bool

func (*ViewImpl) OnStart added in v0.1.1

func (v *ViewImpl) OnStart()

func (*ViewImpl) OnStop added in v0.1.1

func (v *ViewImpl) OnStop()

func (*ViewImpl) ShouldRedraw added in v0.1.1

func (v *ViewImpl) ShouldRedraw() bool

Directories

Path Synopsis
builtin package provides a set of basic components.
builtin package provides a set of basic components.
This package is a wrapper around github.com/cadmean-ru/goRPCKit library adapted for Amphion tasks system.
This package is a wrapper around github.com/cadmean-ru/goRPCKit library adapted for Amphion tasks system.

Jump to

Keyboard shortcuts

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