instance

package
v0.0.0-...-eb9c356 Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package instance implements a standalone structure that is capable of running a game.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartScript

func StartScript(is IInstance, charsToActOn ...component.GOiD) error

Types

type IInstance

type IInstance interface {
	CreateFromMap(mapName string) ([]component.GOiD, error)
	CreateObject(objName string, loc math.Vec3) (component.GOiD, error)
	MoveGameObject(id component.GOiD, newLoc math.Vec3)
	AddQuest(id component.GOiD, questName string)
	RunAi(id component.GOiD)
	RenderFromPerspective(id component.GOiD)

	GetSceneManagerSnapshot() component.SceneManager
	GetEventManager() *event.EventManager

	Tick(dtime float64)
}

type Instance

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

The instance struct is used as an individual structure that is used to encapsulate the game state. Each instance has its own separate state from all other instances. It is the core piece of the game, and it represents one self-suficient portion of a game. Multiple instances could be bound together in a game to represent various levels or zones.

func MakeInstance

func MakeInstance(rm *res.ResourceManager, parentEventDelegate event.EventListener) *Instance

MakeInstance returns a pointer to an Instance. parentEventDelegate is a function that certain events will get passed along to. This will be used to help string together multiple instances to work together. A series of managers for various systems are created inside the function and a fully initialized Instance is returned.

func (*Instance) AddQuest

func (is *Instance) AddQuest(id component.GOiD, questName string)

AddQuest adds a quest using the quest manager.

func (*Instance) CreateFromMap

func (is *Instance) CreateFromMap(mapName string) ([]component.GOiD, error)

CreateFromMap is a helper function to create a map from a filename string.

func (*Instance) CreateObject

func (is *Instance) CreateObject(objName string, loc math.Vec3) (component.GOiD, error)

CreateObject is a helper function to create a GameObject with a starting location.

func (*Instance) GetEventManager

func (is *Instance) GetEventManager() *event.EventManager

GetEventManager returns a pointer to the instance's event manager.

func (*Instance) GetSceneManagerSnapshot

func (is *Instance) GetSceneManagerSnapshot() component.SceneManager

GetSceneManagerSnapshot is used by the graphics manager to request a snapshot of the location data during the current frame. The graphics manager uses this to depict the scene for the current frame without data corruption.

func (*Instance) MoveGameObject

func (is *Instance) MoveGameObject(id component.GOiD, newLoc math.Vec3)

MoveGameObject moves the GameObject in the transform manager.

func (*Instance) RenderFromPerspective

func (is *Instance) RenderFromPerspective(id component.GOiD)

func (*Instance) RunAi

func (is *Instance) RunAi(id component.GOiD)

RunAi calls the RunAi function on the ai manager.

func (*Instance) Tick

func (is *Instance) Tick(secs float64)

Loop is launched as a goroutine and updates on its own. This function does some initialization, but then jumps into an infinite loop. When the loop breaks, a bool will be sent along the returnlink that the instance was created with. The returnlink is expected to be periodically checked for activity because this indicates an exit of the main loop of the instance.

Jump to

Keyboard shortcuts

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