Documentation ¶
Index ¶
- Constants
- func ChangeGold(inv Inventory, dv int) bool
- func Frames(num int) ns4.Duration
- func GetVMSymbol[T any](vm VM, name string) (T, error)
- func GetVMSymbolPtr[T any](vm VM, name string) (*T, error)
- func HasItem(inv Inventory, v Item) bool
- func HitMeleePos(obj OffensiveGroup, to Positioner)
- func HitRangedPos(obj OffensiveGroup, to Positioner)
- func IsAllUnits(list []Object) bool
- func LookAtPos(obj Mobile, to Positioner)
- func MoveToPos(obj Mobile, to Positioner)
- func PushToPos(obj Pushable, to Positioner)
- func RegisterVM(r VMRuntime)
- func SetPos(obj PositionSetter, to Positioner)
- func SetRuntime(g Game)
- func Time(dt time.Duration) ns4.Duration
- func Toggle(obj Enabler) bool
- func ToggleLock(obj Lockable) bool
- func WalkToPos(obj Mobile, to Positioner)
- func WithGame(ctx context.Context, g Game) context.Context
- type BaseGame
- func (BaseGame) AudioEffect(name string, pos Positioner)
- func (BaseGame) BlindPlayers(blind bool)
- func (BaseGame) CinemaPlayers(v bool)
- func (BaseGame) Console(error bool) Printer
- func (BaseGame) Frame() int
- func (BaseGame) Global() Printer
- func (BaseGame) HostPlayer() Player
- func (BaseGame) ObjectByID(id string) Object
- func (BaseGame) ObjectGroupByID(id string) *ObjectGroup
- func (BaseGame) ObjectTypeByID(id string) ObjectType
- func (BaseGame) OnPlayerJoin(fnc func(p Player))
- func (BaseGame) OnPlayerLeave(fnc func(p Player))
- func (BaseGame) Players() []Player
- func (BaseGame) Time() time.Duration
- func (BaseGame) WallAt(pos types.Pointf) Wall
- func (BaseGame) WallAtGrid(pos image.Point) Wall
- func (BaseGame) WallGroupByID(id string) *WallGroup
- func (BaseGame) WallNear(pos types.Pointf) Wall
- func (BaseGame) WaypointByID(id string) Waypoint
- func (BaseGame) WaypointGroupByID(id string) *WaypointGroup
- type BaseObject
- func (BaseObject) Class() object.Class
- func (BaseObject) Delete()
- func (BaseObject) Destroy()
- func (BaseObject) Enable(enable bool)
- func (BaseObject) GetObject() Object
- func (BaseObject) ID() string
- func (BaseObject) IsEnabled() bool
- func (BaseObject) ObjScriptID() int
- func (BaseObject) ObjectType() ObjectType
- func (BaseObject) OnTriggerActivate(fnc func(obj Object))
- func (BaseObject) OnTriggerDeactivate(fnc func())
- func (BaseObject) Owner() Object
- func (BaseObject) Pos() types.Pointf
- func (BaseObject) Push(vec types.Pointf, force float32)
- func (BaseObject) PushTo(p types.Pointf)
- func (BaseObject) ScriptID() int
- func (BaseObject) SetOwner(owner ObjectWrapper)
- func (BaseObject) SetPos(p types.Pointf)
- func (BaseObject) SetZ(z float32)
- func (BaseObject) String() string
- func (BaseObject) Z() float32
- type BasePlayer
- func (BasePlayer) Blind(v bool)
- func (BasePlayer) Cinema(v bool)
- func (BasePlayer) GetObject() Object
- func (BasePlayer) IsHost() bool
- func (BasePlayer) Name() string
- func (BasePlayer) Pos() types.Pointf
- func (BasePlayer) Print(text string)
- func (BasePlayer) SetPos(p types.Pointf)
- func (BasePlayer) String() string
- func (BasePlayer) Unit() Unit
- type BaseWall
- type BaseWaypoint
- type Breakable
- type Chatty
- type Deleter
- type Destroyable
- type Duration
- type EnableSetter
- type Enabler
- type EventType
- type Game
- type GridPositioner
- type Identifiable
- type Inventory
- type Item
- type ItemType
- type Living
- type Lockable
- type LockableObject
- type Mobile
- type Named
- type Object
- type ObjectGroup
- func (g *ObjectGroup) Delete()
- func (g *ObjectGroup) Destroy()
- func (g *ObjectGroup) Enable(enable bool)
- func (g *ObjectGroup) ID() string
- func (g *ObjectGroup) Objects() []Object
- func (g *ObjectGroup) Push(vec types.Pointf, force float32)
- func (g *ObjectGroup) PushTo(pos types.Pointf)
- func (g *ObjectGroup) SetOwner(owner ObjectWrapper)
- func (g *ObjectGroup) SetPos(pos types.Pointf)
- func (g *ObjectGroup) String() string
- func (g *ObjectGroup) Toggle() bool
- type ObjectType
- type ObjectWrapper
- type Offensive
- type OffensiveGroup
- type Ownable
- type Owned
- type OwnerSetter
- type Physical
- type Player
- type PositionSetter
- type Positionable
- type Positioner
- type Printer
- type Pushable
- type Raisable
- type TimeSource
- type Timer
- type Timers
- type Toggler
- type Trigger
- type Unit
- type UnitGroup
- func (g *UnitGroup) Attack(obj Positioner)
- func (g *UnitGroup) Cast(spell spell.ID, level int, target Positioner) bool
- func (g *UnitGroup) Delete()
- func (g *UnitGroup) Destroy()
- func (g *UnitGroup) Enable(enable bool)
- func (g *UnitGroup) Flee(obj Positioner, dur ns4.Duration)
- func (g *UnitGroup) Follow(obj Positioner)
- func (g *UnitGroup) Freeze(freeze bool)
- func (g *UnitGroup) Guard()
- func (g *UnitGroup) HitMelee(pos types.Pointf)
- func (g *UnitGroup) HitRanged(pos types.Pointf)
- func (g *UnitGroup) Hunt()
- func (g *UnitGroup) ID() string
- func (g *UnitGroup) Idle()
- func (g *UnitGroup) LookAngle(ang int)
- func (g *UnitGroup) LookAt(pos types.Pointf)
- func (g *UnitGroup) LookAtDir(dir int)
- func (g *UnitGroup) MoveTo(pos types.Pointf)
- func (g *UnitGroup) Push(vec types.Pointf, force float32)
- func (g *UnitGroup) PushTo(pos types.Pointf)
- func (g *UnitGroup) Return()
- func (g *UnitGroup) SetAggression(val float32)
- func (g *UnitGroup) SetOwner(owner ObjectWrapper)
- func (g *UnitGroup) SetPos(pos types.Pointf)
- func (g *UnitGroup) SetRegroupLevel(val float32)
- func (g *UnitGroup) SetRetreatLevel(val float32)
- func (g *UnitGroup) String() string
- func (g *UnitGroup) Toggle() bool
- func (g *UnitGroup) Units() []Unit
- func (g *UnitGroup) WalkTo(pos types.Pointf)
- func (g *UnitGroup) Wander()
- type VM
- type VMRuntime
- type Wall
- type WallGroup
- type Waypoint
- type WaypointGroup
- type ZPositioner
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ChangeGold ¶
ChangeGold changes the amount of gold by a given amount. It returns false if it cannot be done.
func GetVMSymbol ¶
GetVMSymbol is a generic helper for VM.GetSymbol. It is suitable for functions mostly, since it returns value directly, not a pointer.
func GetVMSymbolPtr ¶
GetVMSymbolPtr is a generic helper for VM.GetSymbol. It is similar to GetVMSymbol, but returns a pointer to the value. Useful for variables.
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 ¶
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 SetPos ¶
func SetPos(obj PositionSetter, to Positioner)
SetPos is a helper to instantly move objects to another object's location.
func Toggle ¶
Toggle is a helper to toggle the object's enabled state. It returns the new state after toggling the object.
func ToggleLock ¶
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.
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) CinemaPlayers ¶
func (BaseGame) HostPlayer ¶
func (BaseGame) ObjectByID ¶
func (BaseGame) ObjectGroupByID ¶
func (BaseGame) ObjectGroupByID(id string) *ObjectGroup
func (BaseGame) ObjectTypeByID ¶
func (BaseGame) ObjectTypeByID(id string) ObjectType
func (BaseGame) OnPlayerJoin ¶
func (BaseGame) OnPlayerLeave ¶
func (BaseGame) WallGroupByID ¶
func (BaseGame) WaypointByID ¶
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) 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.
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 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 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 }
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 ¶
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 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 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) 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 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 ¶
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 Timers ¶
type Timers struct {
// contains filtered or unexported fields
}
func NewTimers ¶
func NewTimers(src ns4.TimeSource) *Timers
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 (*UnitGroup) Attack ¶
func (g *UnitGroup) Attack(obj Positioner)
func (*UnitGroup) Follow ¶
func (g *UnitGroup) Follow(obj Positioner)
func (*UnitGroup) SetAggression ¶
func (*UnitGroup) SetOwner ¶
func (g *UnitGroup) SetOwner(owner ObjectWrapper)
func (*UnitGroup) SetRegroupLevel ¶
func (*UnitGroup) SetRetreatLevel ¶
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.
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 ¶
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.