script

package
v0.0.0-...-63dc931 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventMapInitialize = EventType("MapInitialize")
	EventMapEntry      = EventType("MapEntry")
	EventMapExit       = EventType("MapExit")
	EventMapShutdown   = EventType("MapShutdown")
	EventPlayerDeath   = EventType("PlayerDeath")
)

Variables

This section is empty.

Functions

func ChangeGold

func ChangeGold(inv Inventory, dv int) bool

ChangeGold changes the amount of gold by a given amount. It returns false if it cannot be done.

func Frames

func Frames(num int) ns4.Duration

func GetVMSymbol

func GetVMSymbol[T any](vm VM, name string) (T, error)

GetVMSymbol is a generic helper for VM.GetSymbol. It is suitable for functions mostly, since it returns value directly, not a pointer.

func GetVMSymbolPtr

func GetVMSymbolPtr[T any](vm VM, name string) (*T, error)

GetVMSymbolPtr is a generic helper for VM.GetSymbol. It is similar to GetVMSymbol, but returns a pointer to the value. Useful for variables.

func HasItem

func HasItem(inv Inventory, v Item) bool

HasItem is a helper that checks if inventory contains a given item.

func HitMeleePos

func HitMeleePos(obj OffensiveGroup, to Positioner)

HitMeleePos is a helper to make an objects melee attack another object's location.

func HitRangedPos

func HitRangedPos(obj OffensiveGroup, to Positioner)

HitRangedPos is a helper to make an objects ranged attack another object's location.

func IsAllUnits

func IsAllUnits(list []Object) bool

IsAllUnits checks if all objects in the list are of type Unit.

func LookAtPos

func LookAtPos(obj Mobile, to Positioner)

LookAtPos is a helper to make an objects look at another object's location.

func MoveToPos

func MoveToPos(obj Mobile, to Positioner)

MoveToPos is a helper to make an objects walk to another object's location. More generic than WalkToPos.

func PushToPos

func PushToPos(obj Pushable, to Positioner)

PushToPos is a helper to push objects to another object's location.

func RegisterVM

func RegisterVM(r VMRuntime)

RegisterVM registers a new script VM runtime.

func SetPos

func SetPos(obj PositionSetter, to Positioner)

SetPos is a helper to instantly move objects to another object's location.

func SetRuntime

func SetRuntime(g Game)

SetRuntime sets a global runtime instance.

func Time

func Time(dt time.Duration) ns4.Duration

func Toggle

func Toggle(obj Enabler) bool

Toggle is a helper to toggle the object's enabled state. It returns the new state after toggling the object.

func ToggleLock

func ToggleLock(obj Lockable) bool

ToggleLock is a helper to toggle the object's lock state. It returns the new state after toggling the object.

func WalkToPos

func WalkToPos(obj Mobile, to Positioner)

WalkToPos is a helper to make an objects walk to another object's location.

func WithGame

func WithGame(ctx context.Context, g Game) context.Context

WithGame stores Game reference in the context.

Types

type BaseGame

type BaseGame struct{}

BaseGame implements Game, but panics on all the methods. Useful when you only want to define a part of the implementation.

func (BaseGame) AudioEffect

func (BaseGame) AudioEffect(name string, pos Positioner)

func (BaseGame) BlindPlayers

func (BaseGame) BlindPlayers(blind bool)

func (BaseGame) CinemaPlayers

func (BaseGame) CinemaPlayers(v bool)

func (BaseGame) Console

func (BaseGame) Console(error bool) Printer

func (BaseGame) Frame

func (BaseGame) Frame() int

func (BaseGame) Global

func (BaseGame) Global() Printer

func (BaseGame) HostPlayer

func (BaseGame) HostPlayer() Player

func (BaseGame) ObjectByID

func (BaseGame) ObjectByID(id string) Object

func (BaseGame) ObjectGroupByID

func (BaseGame) ObjectGroupByID(id string) *ObjectGroup

func (BaseGame) ObjectTypeByID

func (BaseGame) ObjectTypeByID(id string) ObjectType

func (BaseGame) OnPlayerJoin

func (BaseGame) OnPlayerJoin(fnc func(p Player))

func (BaseGame) OnPlayerLeave

func (BaseGame) OnPlayerLeave(fnc func(p Player))

func (BaseGame) Players

func (BaseGame) Players() []Player

func (BaseGame) Time

func (BaseGame) Time() time.Duration

func (BaseGame) WallAt

func (BaseGame) WallAt(pos types.Pointf) Wall

func (BaseGame) WallAtGrid

func (BaseGame) WallAtGrid(pos image.Point) Wall

func (BaseGame) WallGroupByID

func (BaseGame) WallGroupByID(id string) *WallGroup

func (BaseGame) WallNear

func (BaseGame) WallNear(pos types.Pointf) Wall

func (BaseGame) WaypointByID

func (BaseGame) WaypointByID(id string) Waypoint

func (BaseGame) WaypointGroupByID

func (BaseGame) WaypointGroupByID(id string) *WaypointGroup

type BaseObject

type BaseObject struct{}

BaseObject implements Object, but panics on all the methods. Useful when you only want to define a part of the implementation.

func (BaseObject) Class

func (BaseObject) Class() object.Class

func (BaseObject) Delete

func (BaseObject) Delete()

func (BaseObject) Destroy

func (BaseObject) Destroy()

func (BaseObject) Enable

func (BaseObject) Enable(enable bool)

func (BaseObject) GetObject

func (BaseObject) GetObject() Object

func (BaseObject) ID

func (BaseObject) ID() string

func (BaseObject) IsEnabled

func (BaseObject) IsEnabled() bool

func (BaseObject) ObjScriptID

func (BaseObject) ObjScriptID() int

func (BaseObject) ObjectType

func (BaseObject) ObjectType() ObjectType

func (BaseObject) OnTriggerActivate

func (BaseObject) OnTriggerActivate(fnc func(obj Object))

func (BaseObject) OnTriggerDeactivate

func (BaseObject) OnTriggerDeactivate(fnc func())

func (BaseObject) Owner

func (BaseObject) Owner() Object

func (BaseObject) Pos

func (BaseObject) Pos() types.Pointf

func (BaseObject) Push

func (BaseObject) Push(vec types.Pointf, force float32)

func (BaseObject) PushTo

func (BaseObject) PushTo(p types.Pointf)

func (BaseObject) ScriptID

func (BaseObject) ScriptID() int

func (BaseObject) SetOwner

func (BaseObject) SetOwner(owner ObjectWrapper)

func (BaseObject) SetPos

func (BaseObject) SetPos(p types.Pointf)

func (BaseObject) SetZ

func (BaseObject) SetZ(z float32)

func (BaseObject) String

func (BaseObject) String() string

func (BaseObject) Z

func (BaseObject) Z() float32

type BasePlayer

type BasePlayer struct{}

BasePlayer implements Player, but panics on all the methods. Useful when you only want to define a part of the implementation.

func (BasePlayer) Blind

func (BasePlayer) Blind(v bool)

func (BasePlayer) Cinema

func (BasePlayer) Cinema(v bool)

func (BasePlayer) GetObject

func (BasePlayer) GetObject() Object

func (BasePlayer) IsHost

func (BasePlayer) IsHost() bool

func (BasePlayer) Name

func (BasePlayer) Name() string

func (BasePlayer) Pos

func (BasePlayer) Pos() types.Pointf

func (BasePlayer) Print

func (BasePlayer) Print(text string)

func (BasePlayer) SetPos

func (BasePlayer) SetPos(p types.Pointf)

func (BasePlayer) String

func (BasePlayer) String() string

func (BasePlayer) Unit

func (BasePlayer) Unit() Unit

type BaseWall

type BaseWall struct{}

BaseWall implements Wall, but panics on all the methods. Useful when you only want to define a part of the implementation.

func (BaseWall) Destroy

func (BaseWall) Destroy()

func (BaseWall) Enable

func (BaseWall) Enable(enable bool)

func (BaseWall) GridPos

func (BaseWall) GridPos() image.Point

func (BaseWall) IsEnabled

func (BaseWall) IsEnabled() bool

func (BaseWall) Pos

func (BaseWall) Pos() types.Pointf

func (BaseWall) String

func (BaseWall) String() string

type BaseWaypoint

type BaseWaypoint struct{}

BaseWaypoint implements Waypoint, but panics on all the methods. Useful when you only want to define a part of the implementation.

func (BaseWaypoint) Enable

func (BaseWaypoint) Enable(enable bool)

func (BaseWaypoint) ID

func (BaseWaypoint) ID() string

func (BaseWaypoint) IsEnabled

func (BaseWaypoint) IsEnabled() bool

func (BaseWaypoint) Pos

func (BaseWaypoint) Pos() types.Pointf

func (BaseWaypoint) SetPos

func (BaseWaypoint) SetPos(p types.Pointf)

func (BaseWaypoint) String

func (BaseWaypoint) String() string

func (BaseWaypoint) Toggle

func (BaseWaypoint) Toggle() bool

type Breakable

type Breakable interface {
	Destroyable
	// Health returns current and max health of the object.
	Health() (cur, max int)
	// SetHealth sets the amount of health of the object. It will be limited by max health.
	SetHealth(v int)
	// SetMaxHealth sets the maximal amount of health of the object. It will be adjust health accordingly.
	SetMaxHealth(v int)
}

Breakable is an interface for objects that has health and can be broken.

type Chatty

type Chatty interface {
	// Say displays the chat bubble on this object.
	// If the duration is set, the bubble will disappear after it passes.
	Say(text string, dur ns4.Duration)
	// Mute removes the current chat bubble, if any.
	Mute()
}

Chatty is an interface for objects that can say stuff.

type Deleter

type Deleter interface {
	// Delete the object permanently.
	Delete()
}

Deleter is an interface for objects that can be deleted.

type Destroyable

type Destroyable interface {
	// Destroy this object. Implies reducing health to zero and playing break/death effects.
	Destroy()
}

Destroyable is an interface for objects can be broken, destroyed or killed.

type Duration

type Duration = ns4.Duration

type EnableSetter

type EnableSetter interface {
	// Enable or disable the object.
	Enable(enable bool)
}

EnableSetter is an interface for objects that can be enabled and disabled.

type Enabler

type Enabler interface {
	// IsEnabled checks if object is currently enabled.
	IsEnabled() bool
	EnableSetter
}

Enabler is an interface for objects that can be enabled or disabled.

type EventType

type EventType string

EventType is a type of script events.

type Game

type Game interface {
	TimeSource

	// BlindPlayers blinds or unblinds all players.
	BlindPlayers(blind bool)
	// CinemaPlayers enables a wide-screen "cinema" mode for all players.
	CinemaPlayers(v bool)
	// Players returns a list of all players.
	Players() []Player
	// HostPlayer returns the host player.
	HostPlayer() Player
	// OnPlayerJoin registers a player join event handler.
	OnPlayerJoin(fnc func(p Player))
	// OnPlayerLeave registers a player leave event handler.
	OnPlayerLeave(fnc func(p Player))

	// ObjectTypeByID finds an object type by ID.
	ObjectTypeByID(id string) ObjectType
	// ObjectByID finds an object by ID.
	ObjectByID(id string) Object
	// ObjectGroupByID finds an object group by ID.
	ObjectGroupByID(id string) *ObjectGroup

	// WaypointByID finds a waypoint by ID.
	WaypointByID(id string) Waypoint
	// WaypointGroupByID finds a waypoint group by ID.
	WaypointGroupByID(id string) *WaypointGroup

	// WallAt finds a wall by its position.
	WallAt(pos types.Pointf) Wall
	// WallNear finds a wall near the position.
	WallNear(pos types.Pointf) Wall
	// WallAtGrid finds a wall by its grid position.
	WallAtGrid(pos image.Point) Wall
	// WallGroupByID finds a wall group by ID.
	WallGroupByID(id string) *WallGroup

	// AudioEffect creates an audio effect with a given name at a specified position. Position can be nil.
	AudioEffect(name string, pos Positioner)

	Global() Printer
	Console(error bool) Printer
}

func GetGame

func GetGame(ctx context.Context) Game

GetGame loads Game from the context.

func Runtime

func Runtime() Game

Runtime returns a global runtime instance.

type GridPositioner

type GridPositioner interface {
	// GridPos returns current position of the object on the grid.
	GridPos() image.Point
}

GridPositioner is an interface for objects that has position on the map.

type Identifiable

type Identifiable interface {
	fmt.Stringer
	// ID of the object.
	ID() string
}

Identifiable is an interface for objects with unique string ID.

type Inventory

type Inventory interface {
	// CountItem counts the number of given items in the inventory.
	CountItem(v Item) int
	// Items returns a list of all items. It ignores the stack size.
	Items() []Item
	// Gold returns amount of gold this inventory contains.
	Gold() int
	// SetGold sets the amount of gold this inventory contains.
	SetGold(v int)
}

Inventory is an interface for objects that can contain items.

type Item

type Item interface {
	Named
	// ItemType returns a type of this item.
	ItemType() ItemType
	// Amount returns current amount of this item.
	Amount() int
	// SetAmount sets an amount of a given item.
	SetAmount(v int)
	// CanStack checks if two items can be stacked together.
	CanStack(v Item) bool
}

Item is an interface for generic items.

type ItemType

type ItemType interface {
	Named
	// MaxStack returns maximal amount of this item an inventory slot can contain.
	MaxStack() int
}

ItemType is an interface that defines an item type.

type Living

type Living interface {
	Breakable
	// Mana returns current and max mana of the unit.
	Mana() (cur, max int)
	// SetMana sets the amount of mana of the object. It will be limited by max mana.
	SetMana(v int)
	// SetMaxMana sets the maximal amount of mana of the object. It will be adjust mana accordingly.
	SetMaxMana(v int)
}

Living is an interface for objects that are alive.

type Lockable

type Lockable interface {
	// IsLocked checks if object is currently locked.
	IsLocked() bool
	// Lock or unlock the object.
	Lock(lock bool)
}

Lockable is an interface for objects that can be locked.

type LockableObject

type LockableObject interface {
	Object
	Lockable
}

type Mobile

type Mobile interface {
	// MoveTo forces the unit to move to a location. More generic than WalkTo.
	MoveTo(p types.Pointf)
	// WalkTo forces the unit to walk to a location.
	WalkTo(p types.Pointf)
	// LookAt forces the unit to look at the location.
	LookAt(p types.Pointf)
	// LookAtDir forces the unit to look in a given direction.
	LookAtDir(dir int)
	// LookAngle forces unit to look at a given angle.
	LookAngle(ang int)
	// Freeze or unfreeze an object in place.
	Freeze(freeze bool)
	// Wander makes this unit wander around.
	Wander()
	// Return makes this unit to return to its starting position.
	Return()
	// Idle makes an object idle.
	Idle()
	// Follow a given object.
	Follow(obj Positioner)
	// Flee from a given object for a certain duration.
	Flee(obj Positioner, dur ns4.Duration)
}

Mobile is an interface for objects that can move around on their own.

type Named

type Named interface {
	fmt.Stringer
	// Name returns a name of the item.
	Name() string
}

Named is an interface for objects with a human-readable name.

type Object

type Object interface {
	// ScriptID returns internal script ID for the object.
	ScriptID() int
	// ObjScriptID returns internal script ID for the object.
	ObjScriptID() int
	Identifiable
	ObjectWrapper
	Class() object.Class
	ObjectType() ObjectType
	Ownable
	Physical
	Enabler
	Deleter
	Destroyable
	Trigger // TODO: move those to a separate type eventually
}

type ObjectGroup

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

func NewObjectGroup

func NewObjectGroup(id string, list ...Object) *ObjectGroup

func (*ObjectGroup) Delete

func (g *ObjectGroup) Delete()

func (*ObjectGroup) Destroy

func (g *ObjectGroup) Destroy()

func (*ObjectGroup) Enable

func (g *ObjectGroup) Enable(enable bool)

func (*ObjectGroup) ID

func (g *ObjectGroup) ID() string

func (*ObjectGroup) Objects

func (g *ObjectGroup) Objects() []Object

func (*ObjectGroup) Push

func (g *ObjectGroup) Push(vec types.Pointf, force float32)

func (*ObjectGroup) PushTo

func (g *ObjectGroup) PushTo(pos types.Pointf)

func (*ObjectGroup) SetOwner

func (g *ObjectGroup) SetOwner(owner ObjectWrapper)

func (*ObjectGroup) SetPos

func (g *ObjectGroup) SetPos(pos types.Pointf)

func (*ObjectGroup) String

func (g *ObjectGroup) String() string

func (*ObjectGroup) Toggle

func (g *ObjectGroup) Toggle() bool

type ObjectType

type ObjectType interface {
	Identifiable
	CreateObject(p types.Pointf) Object
}

type ObjectWrapper

type ObjectWrapper interface {
	// GetObject returns an underlying object.
	GetObject() Object
}

ObjectWrapper is an interface for types that wrap Object.

type Offensive

type Offensive interface {
	OffensiveGroup
	// Aggression returns current aggression level.
	Aggression() float32
	// RetreatLevel returns current retreat level.
	RetreatLevel() float32
	// RegroupLevel returns current regroup level.
	RegroupLevel() float32
}

Offensive is an interface for objects that can attack or defend.

type OffensiveGroup

type OffensiveGroup interface {
	// SetAggression sets aggression level.
	SetAggression(v float32)
	// SetRetreatLevel sets retreat level, causing the creature to flee on low health.
	SetRetreatLevel(v float32)
	// SetRegroupLevel sets regroup level, causing the creature to return to fight when health restores.
	SetRegroupLevel(v float32)
	// Attack another object.
	Attack(obj Positioner)
	// HitMelee forces the unit to melee attack the location.
	HitMelee(p types.Pointf)
	// HitRanged forces the unit to ranged attack the location.
	HitRanged(p types.Pointf)
	// Guard makes an object guard location.
	Guard()
	// Hunt makes an object hunt for enemies.
	Hunt()
	// Cast a specific spell level at a given location. If location is nil, it will be cast on self.
	Cast(spell spell.ID, level int, target Positioner) bool
}

OffensiveGroup is an interface for a group of objects that can attack or defend.

type Ownable

type Ownable interface {
	Owned
	OwnerSetter
}

Ownable is an interface for objects that has and can be assigned an owner.

type Owned

type Owned interface {
	Owner() Object
}

Owned is an interface for objects with an owner.

type OwnerSetter

type OwnerSetter interface {
	SetOwner(owner ObjectWrapper)
}

OwnerSetter is an interface for objects that can be assigned an owner.

type Physical

type Physical interface {
	Raisable
	Pushable
}

Physical is an interface for objects that are affected by physics.

type Player

type Player interface {
	ObjectWrapper // proxies to Unit
	Positionable  // proxies to Unit
	Named
	// IsHost checks if this player hosts the game.
	IsHost() bool
	Printer
	// Blind or unblind the player.
	Blind(v bool)
	// Cinema enables wide-screen "cinema" mode.
	Cinema(v bool)
	// Unit that the player controls.
	Unit() Unit
}

type PositionSetter

type PositionSetter interface {
	// SetPos instantly moves object to a given position.
	SetPos(p types.Pointf)
}

PositionSetter is an interface for objects that can be moved.

type Positionable

type Positionable interface {
	Positioner
	PositionSetter
}

Positionable is a combined interface for objects for which you can get and set the position.

type Positioner

type Positioner interface {
	// Pos returns current position of the object.
	Pos() types.Pointf
}

Positioner is an interface for objects that has position on the map.

type Printer

type Printer interface {
	// Print a text message.
	Print(text string)
}

Printer is an interface for printing messages.

type Pushable

type Pushable interface {
	// Push applies a force to the object based on the vector and magnitude.
	Push(vec types.Pointf, force float32)
	// PushTo pushes an object to a specific location.
	PushTo(p types.Pointf)
}

Pushable is an interface for objects that can be pushed.

type Raisable

type Raisable interface {
	Positionable
	ZPositioner
	// SetZ sets Z offset for the object.
	SetZ(z float32)
}

Raisable is an interface for positionable objects that can also be raised or lowered by Z axis.

type TimeSource

type TimeSource = ns4.TimeSource

type Timer

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

func (*Timer) Stop

func (t *Timer) Stop()

type Timers

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

func NewTimers

func NewTimers(src ns4.TimeSource) *Timers

func (*Timers) SetTimer

func (t *Timers) SetTimer(d ns4.Duration, fnc func()) *Timer

func (*Timers) Tick

func (t *Timers) Tick()

type Toggler

type Toggler interface {
	// Toggle the object's enabled state.
	// It returns the new state after toggling the object.
	Toggle() bool
}

Toggler is an interface for objects that can be toggled.

type Trigger

type Trigger interface {
	OnTriggerActivate(fnc func(obj Object))
	OnTriggerDeactivate(fnc func())
}

type Unit

type Unit interface {
	Object
	// CanSee checks if this unit can see an object.
	CanSee(obj Object) bool
	Living
	Mobile
	Offensive
	Chatty // TODO: should be on object?
	// OnUnitDeath calls the function when the unit dies.
	OnUnitDeath(fnc func())
	// OnUnitIdle calls the function when the unit becomes idle.
	OnUnitIdle(fnc func())
	// OnUnitDone calls the function when the unit completes its task.
	OnUnitDone(fnc func())
	// OnUnitAttack calls the function when the unit starts attacking another unit.
	OnUnitAttack(fnc func(targ Unit))
	// OnUnitSeeEnemy calls the function when the unit notices an enemy.
	OnUnitSeeEnemy(fnc func(targ Unit))
	// OnUnitLostEnemy calls the function when the unit loses sight of an enemy.
	OnUnitLostEnemy(fnc func(targ Unit))
}

type UnitGroup

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

func NewUnitGroup

func NewUnitGroup(id string, list ...Unit) *UnitGroup

func (*UnitGroup) Attack

func (g *UnitGroup) Attack(obj Positioner)

func (*UnitGroup) Cast

func (g *UnitGroup) Cast(spell spell.ID, level int, target Positioner) bool

func (*UnitGroup) Delete

func (g *UnitGroup) Delete()

func (*UnitGroup) Destroy

func (g *UnitGroup) Destroy()

func (*UnitGroup) Enable

func (g *UnitGroup) Enable(enable bool)

func (*UnitGroup) Flee

func (g *UnitGroup) Flee(obj Positioner, dur ns4.Duration)

func (*UnitGroup) Follow

func (g *UnitGroup) Follow(obj Positioner)

func (*UnitGroup) Freeze

func (g *UnitGroup) Freeze(freeze bool)

func (*UnitGroup) Guard

func (g *UnitGroup) Guard()

func (*UnitGroup) HitMelee

func (g *UnitGroup) HitMelee(pos types.Pointf)

func (*UnitGroup) HitRanged

func (g *UnitGroup) HitRanged(pos types.Pointf)

func (*UnitGroup) Hunt

func (g *UnitGroup) Hunt()

func (*UnitGroup) ID

func (g *UnitGroup) ID() string

func (*UnitGroup) Idle

func (g *UnitGroup) Idle()

func (*UnitGroup) LookAngle

func (g *UnitGroup) LookAngle(ang int)

func (*UnitGroup) LookAt

func (g *UnitGroup) LookAt(pos types.Pointf)

func (*UnitGroup) LookAtDir

func (g *UnitGroup) LookAtDir(dir int)

func (*UnitGroup) MoveTo

func (g *UnitGroup) MoveTo(pos types.Pointf)

func (*UnitGroup) Push

func (g *UnitGroup) Push(vec types.Pointf, force float32)

func (*UnitGroup) PushTo

func (g *UnitGroup) PushTo(pos types.Pointf)

func (*UnitGroup) Return

func (g *UnitGroup) Return()

func (*UnitGroup) SetAggression

func (g *UnitGroup) SetAggression(val float32)

func (*UnitGroup) SetOwner

func (g *UnitGroup) SetOwner(owner ObjectWrapper)

func (*UnitGroup) SetPos

func (g *UnitGroup) SetPos(pos types.Pointf)

func (*UnitGroup) SetRegroupLevel

func (g *UnitGroup) SetRegroupLevel(val float32)

func (*UnitGroup) SetRetreatLevel

func (g *UnitGroup) SetRetreatLevel(val float32)

func (*UnitGroup) String

func (g *UnitGroup) String() string

func (*UnitGroup) Toggle

func (g *UnitGroup) Toggle() bool

func (*UnitGroup) Units

func (g *UnitGroup) Units() []Unit

func (*UnitGroup) WalkTo

func (g *UnitGroup) WalkTo(pos types.Pointf)

func (*UnitGroup) Wander

func (g *UnitGroup) Wander()

type VM

type VM interface {
	// Exec executes text as a script source code.
	Exec(s string) (reflect.Value, error)
	// ExecFile executes a script from the file or directory.
	ExecFile(path string) error
	// OnFrame must be called when a new game frame is complete.
	OnFrame()
	// OnEvent is called when a certain scrip event happens.
	OnEvent(typ EventType)
	// GetSymbol tries to find a function or variable with a given name and type.
	// If symbol is found, but type doesn't match, it returns an error.
	// If symbol is not found, it returns reflect.Value{}, false, nil.
	GetSymbol(name string, typ reflect.Type) (reflect.Value, bool, error)
	// Close the VM and free resources.
	Close() error
}

VM is an interface for a virtual machine running the script engine.

type VMRuntime

type VMRuntime struct {
	// Log is the logger for this VM runtime.
	Log *log.Logger
	// Name is a short name for the VM runtime. Must be unique.
	Name string
	// Title is a human-friendly name for the VM runtime.
	Title string
	// NewMap creates a new script VM for map scripts.
	// If there's no scripts for the map, function may return nil, nil.
	NewMap func(g Game, maps string, name string) (VM, error)
}

VMRuntime is a type for registering new script runtime implementations.

func VMRuntimes

func VMRuntimes() []VMRuntime

VMRuntimes returns all registered VM runtimes.

type Wall

type Wall interface {
	fmt.Stringer
	Positioner
	GridPositioner
	Enabler // opens and closes the wall
	Destroyable
}

type WallGroup

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

func NewWallGroup

func NewWallGroup(id string, list ...Wall) *WallGroup

func (*WallGroup) Destroy

func (g *WallGroup) Destroy()

func (*WallGroup) Enable

func (g *WallGroup) Enable(enable bool)

func (*WallGroup) ID

func (g *WallGroup) ID() string

func (*WallGroup) String

func (g *WallGroup) String() string

func (*WallGroup) Toggle

func (g *WallGroup) Toggle() bool

func (*WallGroup) Walls

func (g *WallGroup) Walls() []Wall

type Waypoint

type Waypoint interface {
	Identifiable
	Enabler
	Positionable
}

type WaypointGroup

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

func NewWaypointGroup

func NewWaypointGroup(id string, list ...Waypoint) *WaypointGroup

func (*WaypointGroup) Enable

func (g *WaypointGroup) Enable(enable bool)

func (*WaypointGroup) ID

func (g *WaypointGroup) ID() string

func (*WaypointGroup) SetPos

func (g *WaypointGroup) SetPos(pos types.Pointf)

func (*WaypointGroup) String

func (g *WaypointGroup) String() string

func (*WaypointGroup) Toggle

func (g *WaypointGroup) Toggle() bool

func (*WaypointGroup) Waypoints

func (g *WaypointGroup) Waypoints() []Waypoint

type ZPositioner

type ZPositioner interface {
	// Z returns current Z offset for the object.
	Z() float32
}

ZPositioner is an interface for objects that has Z position.

Directories

Path Synopsis
lua

Jump to

Keyboard shortcuts

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