action

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnimationMoveUp    string = "MoveUp"
	AnimationMoveDown  string = "MoveDown"
	AnimationMoveLeft  string = "MoveLeft"
	AnimationMoveRight string = "MoveRight"
	AnimationStopUp    string = "StopUp"
	AnimationStopDown  string = "StopDown"
	AnimationStopLeft  string = "StopLeft"
	AnimationStopRight string = "StopRight"
)

Animation names for Entities to implement, used by ActionSystem to trigger Animations.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Type determines what to do to the Entity
	// and how to interpret the other Action fields.
	Type ActionType

	// Point is the relevant engo.Point for the action.
	// ActionTypes can use Point in different ways,
	// refer to the ActionType for more information.
	//
	// Examples:
	//  - ActWalk uses Point as a direction.
	//  - ActWalkTo uses Point as a location.
	//
	// When Point is a direction, the Action will be complete
	// after the Duration has passed. If Duration == 0, the
	// Action will be complete after one system update.
	//
	// When Point is a location, the Action will be complete
	// after the Point is reached and the Duration has passed.
	engo.Point

	// Duration sets how long the Action should run for,
	// if Duration is 0 the Action runs until complete.
	// Note that Duration may not affect all ActionTypes.
	Duration float32
}

An Action defines a single act for a Entity. Actions are used to create Schedules.

type ActionComponent

type ActionComponent struct {
	Schedule
}

ActionComponent marks entities for use with a ActionSystem.

func (*ActionComponent) GetActionComponent

func (ac *ActionComponent) GetActionComponent() *ActionComponent

GetActionComponent provides type safe access to ActionComponent.

type ActionFace

type ActionFace interface {
	GetActionComponent() *ActionComponent
}

ActionFace enforces type safe access to underlying ActionComponent.

type ActionSystem

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

ActionSystem handles action-specific operations.

func (*ActionSystem) Add

Add an entity to the ActionSystem.

func (*ActionSystem) AddByInterface

func (as *ActionSystem) AddByInterface(i ecs.Identifier)

AddByInterface adds entities to the system via Actionable interface.

func (*ActionSystem) Remove

func (as *ActionSystem) Remove(b ecs.BasicEntity)

Remove an entity from the ActionSystem.

func (*ActionSystem) Update

func (as *ActionSystem) Update(dt float32)

Update the ActionSystem this frame.

type ActionType

type ActionType int

ActionType indicates the type of an Action.

const (
	// ActStop stops movement, preserving the direction.
	ActStop ActionType = iota

	// ActTurn turns the Entity to face the direction
	// indicated by Point and stops movement.
	ActTurn

	// ActWalk makes the Entity walk in the direction
	// indicated by Point until Duration has passed.
	ActWalk

	// ActRun makes the Entity run in the direction
	// indicated by Point until Duration has passed.
	ActRun

	// ActTeleport teleports the Entity in the direction
	// indicated by Point until Duration has passed.
	ActTeleport

	// ActTurnTo turns the Entity to face the location
	// indicated by Point and updates the SpeedComponent.
	ActTurnTo

	// ActWalkTo walks the Entity to the location indicated by Point.
	ActWalkTo

	// ActRunTo runs the Entity to the location indicated by Point.
	ActRunTo

	// ActTeleportTo teleports the Entity to the location indicated by Point.
	ActTeleportTo
)

ActionTypes available for use in Schedules.

type Actionable

Actionable defines requirements for adding entities to the ActionSystem automatically.

type Schedule

type Schedule struct {
	Actions []Action
	Loop    bool
	// contains filtered or unexported fields
}

A Schedule contains a list of Actions to perform.

func (*Schedule) CurrentAction

func (s *Schedule) CurrentAction() *Action

CurrentAction returns the current Action for the Schedule.

func (*Schedule) StepAction

func (s *Schedule) StepAction()

StepAction steps the Schedule to the next Action. If the current Action is the final Action in the Schedule, the Schedule starts from the beginning.

Jump to

Keyboard shortcuts

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