overworld

package
v0.0.0-...-47a16e8 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SquadToken represents the Token for a Squad.
	SquadToken TokenType = 1
	// GateToken represents the Token for an exit gate.
	GateToken = 2
	// MerchantToken represents a stop where the player can buy stuff.
	MerchantToken = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive interface {
	PedestalAppearances(sinister bool) []int
	GetRecipes() []*Recipe
	GetAnimation(name string) game.FrameAnimation
}

type CollisionSystem

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

CollisionSystem generates collision events when two Tokens occupy the same node.

func NewCollisionSystem

func NewCollisionSystem(mgr *ecs.World, bus *event.Bus) *CollisionSystem

NewCollisionSystem creates a new Collision System.

type CombatInitiated

type CombatInitiated struct {
	Squads []ecs.Entity
}

CombatInitiated occurs when the player has met another squad for combat.

func (CombatInitiated) Type

func (CombatInitiated) Type() event.Type

Type of the Event.

type Complete

type Complete struct{}

Complete happens when the player escapes the current overworld through the gate.

func (Complete) Type

func (Complete) Type() event.Type

Type of the Event.

type InterestRoll

type InterestRoll struct {
	Pick    int
	Options []geom.Key
}

InterestRoll contains a slice of Options to pick from, and a number of times to pick.

type KeyPair

type KeyPair struct {
	First  geom.Key
	Second geom.Key
}

KeyPair is a pair of geom.Keys that represents a linkage between two overworld nodes.

type Manager

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

Manager is a game state that allows the player to pick which path to take, and which combat to enter etc.

func NewManager

func NewManager(mgr *ecs.World, bus *event.Bus, archive Archive) *Manager

NewManager creates a new overworld Manager.

func (*Manager) Begin

func (m *Manager) Begin(seed int64)

Begin a Manager session.

func (*Manager) Disable

func (m *Manager) Disable()

Disable the overworld Manager, ignoring input and not rendering the state of the overworld.

func (*Manager) Enable

func (m *Manager) Enable()

Enable the overworld Manager, responding to input and rendering the state of the overworld.

func (*Manager) End

func (m *Manager) End()

End should be called when the current overworld map is complete, and the player is selecting another map to go to.

func (*Manager) MousePosition

func (m *Manager) MousePosition(x, y int)

MousePosition handles a change in the mouse position from the player.

func (*Manager) Run

func (m *Manager) Run(elapsed time.Duration)

Run the Manager.

type Map

type Map struct {
	// Terrain stores the visible tiles of an overworld.
	Terrain map[geom.Key]TileID

	// Nodes stores the stops on the overworld, and the traversable paths
	// between them.
	Nodes map[geom.Key]*Node

	// Enemies stores rolled enemy squad locations and their types.
	Enemies map[geom.Key][]*game.Character

	// Start stores the rolled location for where the player should start in
	// this overworld map.
	Start geom.Key

	// Gate stores the location of the exit to this overworld.
	Gate geom.Key
}

Map of an overworld.

func (*Map) SortedNodeKeys

func (m *Map) SortedNodeKeys() []geom.Key

SortedNodeKeys provides the geom.Keys that appear in the Nodes map, sorted by M, then N.

type Node

type Node struct {
	ID geom.Key

	// Connected neighbors mapped by the direction they lie.
	Connected map[geom.DirectionType]geom.Key
	// contains filtered or unexported fields
}

Node is a stop on the overworld that might be occupied by the player, an encounter with an enemy squad, the escape portal, a merchant, etc, or nothing at all.

type Recipe

type Recipe struct {
	Label string

	// Terrain stores the visible tiles of an overworld.
	Terrain map[geom.Key]TileID

	// Paths between nodes that are permitted to be generated.
	Paths []KeyPair

	// Interesting stores locations in the map that should always be included as
	// part of the generated Nodes.
	Interesting []InterestRoll
}

Recipe stores configuration of how to roll a map.

func ParseRecipe

func ParseRecipe(r io.Reader) (*Recipe, error)

ParseRecipe parses the bytes of a recipe file into a Recipe.

type State

type State int

State enumerates the States that an Overworld could be in.

const (
	// Uninitialised is before the overworld Manager has been Begun().
	Uninitialised State = iota

	// AnimatingState is when a squad is moving.
	AnimatingState

	// AwaitingInputState is when the Overworld is waiting for the local, human player to move their Squad.
	AwaitingInputState

	// FadingIn is when the combat is first starting, or returning from a menu,
	// and the curtain that obscures the scene change is disappearing.
	FadingIn
	//FadingOut is when the combat is going to another scene, and the curtain
	//that obscures the scene change is appearing.
	FadingOut
)

func (State) String

func (i State) String() string

type TileID

type TileID int
const (
	Grass TileID = iota
	Stone
	Trees
)

type Token

type Token struct {
	Key      geom.Key
	Presence ecs.Entity
	// type? Squad, Gate, Merchant, etc?
	Category TokenType
}

Token represents a presence on the overworld map. This might be an enemy Squad, the exit gate, a merchant, or rest stop.

func (Token) Type

func (Token) Type() string

Type of this Component.

type TokenMoved

type TokenMoved struct {
	E    ecs.Entity
	From geom.Key
	To   geom.Key
}

func (TokenMoved) Type

func (TokenMoved) Type() event.Type

Type of the Event.

type TokenType

type TokenType int

TokenType represents a category of owner for the Token. The values are unusual increments so that their sum can show which types collided.

func (TokenType) String

func (i TokenType) String() string

type TokensCollided

type TokensCollided struct {
	E1, E2 ecs.Entity
	At     geom.Key
}

func (TokensCollided) Type

func (TokensCollided) Type() event.Type

Type of the Event.

type Traversal

type Traversal struct {
	Duration time.Duration

	Destination game.Center

	Complete func()
	// contains filtered or unexported fields
}

Traversal is a Component that changes the X and Y coordinates of an Entity over time.

func (Traversal) Type

func (Traversal) Type() string

Type of this Component.

type TraversalSystem

type TraversalSystem struct{}

TraversalSystem manager Traversal Components.

func (*TraversalSystem) Update

func (ts *TraversalSystem) Update(mgr *ecs.World, elapsed time.Duration)

Update all Traversal Components.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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