src

package
v0.0.0-...-d8a9083 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CELL_WATER  uint32 = 0x0
	CELL_PLAINS uint32 = 0x1
	CELL_BEACH  uint32 = 0x2
)
View Source
const (
	CLogPath = "./clogs.txt"
	SLogPath = "./slogs.txt"
)
View Source
const (
	CLIENT = 0x1 << 1
	SERVER = 0x1 << 2
	PORT   = ":7777"

	// used by the client to indicate it wants to go to the next turn
	CLIENT_CMD_NEXT_TURN = 0x1
	// used by the client to tell the server it is moving a unit
	CLIENT_CMD_MOVE_UNIT = 0x2

	// used to broadcast to all clients
	BROADCAST = 0x0
	// directed to one client
	DIRECT = 0x1
	// used when the server tells the clients it is the next turn
	SERVER_CMD_NEXT_TURN = 0x98
	// used by the server to indicate clients should sync
	SERVER_CMD_SYNC = 0x99
	// used by the server to tell a client they are being initialised
	SERVER_CMD_CLIENT_INIT = 0xA0
)
View Source
const (
	PRESS = 0x0
	HELD  = 0x1

	CAM_SPEED = 0x3

	CELL_DEPTH       = 0x0
	STRUCTURES_DEPTH = 0x1
	UNITS_DEPTH      = 0x2
	UI_DEPTH         = 0x3
)
View Source
const (
	DEFAULT_WIDTH  = 200
	DEFAULT_HEIGHT = 100

	WORLD_VIEW  = 0x0
	SCREEN_VIEW = 0x1

	Z_DEPTH = 0x4
)

Variables

View Source
var (
	Running   = true
	WaitGroup sync.WaitGroup
)
View Source
var (
	CLogFile *os.File
	CWriter  *bufio.Writer
	SLogFile *os.File
	SWriter  *bufio.Writer
)
View Source
var (
	ScreenMutex = sync.Mutex{}
	InputBuffer = InputData{}
)

Functions

func Buf

func Buf(width, height int) tcell.CellBuffer

func BufRune

func BufRune(buf tcell.CellBuffer, rune rune, style tcell.Style, pos Vec) tcell.CellBuffer

fill a cell buffer with text

func BufText

func BufText(buf tcell.CellBuffer, text string, style tcell.Style, pos Vec) tcell.CellBuffer

fill a cell buffer with text

func CLog

func CLog(data ...interface{})

func CLogErr

func CLogErr(err error)

func CloseLogs

func CloseLogs()

func Connect

func Connect()

func FillBufRune

func FillBufRune(rune rune, style tcell.Style) tcell.CellBuffer

fill a cell buffer with text

func Host

func Host()

func InitLogs

func InitLogs()

func Run

func Run()

func SLog

func SLog(data ...interface{})

func SLogErr

func SLogErr(err error)

func Singleplayer

func Singleplayer()

Types

type AttackComponent

type AttackComponent struct {
	Damage float64
}

func (*AttackComponent) Test

func (A *AttackComponent) Test()

type Callback

type Callback func()

type Cell

type Cell struct {
	*Entity
	*SyncComp
	*PosComp
	*RenderComp
	*CellDatComp
}

type CellDatComp

type CellDatComp struct {
	Type         uint32
	Arable       float64
	Contaminated float64
}

type ClickEvent

type ClickEvent struct {
	EventBase
	Button    rune
	ScreenPos Vec
	WorldPos  Vec
	Layer     int
	Type      uint8
}

type Client

type Client struct {
	ECS    *ECS
	Screen *Screen
}

func NewClient

func NewClient(addr string) *Client

func (*Client) Close

func (Client *Client) Close()

func (*Client) Init

func (Client *Client) Init()

func (*Client) Process

func (Client *Client) Process()

process all updatable entities

type ClientCommandEvent

type ClientCommandEvent struct {
	EventBase // whether the command is on the server or client side
	Side      uint8
	Type      uint32
	Data      string
}

used by clients to send commands to the server

type Closer

type Closer interface {
	Close()
}

type Component

type Component interface{}

type DestroyWinEvent

type DestroyWinEvent struct {
	ID string
}

event to destroy a window

type ECS

type ECS struct {
	// number of entities
	Size int
	// store a map of each priority level containing systems
	Systems [][]System
	// store a reference to each entity
	Entities map[uint32]*Entity
	// we store a type registry to store the type of a component
	EntityNameTypeRegistry      map[string]reflect.Type // we store a type registry to store the type of a component
	EntityComponentTypeRegistry map[string][]reflect.Type
	// store a reference to the components attached to the entity (linearly added)
	Components []Component
	// used as an index lookup to find the position of the first component of the particular entity
	EntityComponentLookup map[uint32]uint32
	// whether the ECS is a server or client
	HostMode uint8

	// this is used for the goroutines that poll client/server commands
	// to dispatch events into the ECS in a thread-safe manner
	EventChannel chan Event
}

func NewECS

func NewECS(mode uint8) *ECS

func (*ECS) AddCell

func (ECS *ECS) AddCell(cell *Cell)

func (*ECS) AddEmpire

func (ECS *ECS) AddEmpire(name string, pos Vec, dirty bool)

func (*ECS) AddEntity

func (ECS *ECS) AddEntity(Entity *Entity, components ...Component)

add an entity to the system. this is useful for querying components this is likely only used to know which components an entity has

func (*ECS) AddPlayer

func (ECS *ECS) AddPlayer(name string) uint32

func (*ECS) AddSettlement

func (ECS *ECS) AddSettlement(settlement *Settlement) uint32

func (*ECS) AddState

func (ECS *ECS) AddState(state *State) uint32

add a new player state to the game

func (*ECS) AddUnit

func (ECS *ECS) AddUnit(unit *Unit) uint32

func (*ECS) Close

func (ECS *ECS) Close()

func (*ECS) CreateCell

func (ECS *ECS) CreateCell(pos Vec, cellType uint32, dirty bool) *Cell

func (*ECS) CreateSettlement

func (ECS *ECS) CreateSettlement(name string, pos Vec, dirty bool) *Settlement

func (*ECS) CreateState

func (ECS *ECS) CreateState(id string, dirty bool) *State

func (*ECS) CreateUnit

func (ECS *ECS) CreateUnit(pos Vec, dirty bool) *Unit

func (*ECS) Event

func (ECS *ECS) Event(Event Event)

fire an event into the ECS

func (*ECS) GetEntity

func (ECS *ECS) GetEntity(id uint32) *Entity

func (*ECS) GetEntityComponents

func (ECS *ECS) GetEntityComponents(id uint32) []Component

get all the components attached to a particular entity this is likely only used for serialization and de-serialization as the only accessable data this will return is the ability to call Serialize() and Deserialize()

func (*ECS) Init

func (ECS *ECS) Init()

func (*ECS) NewEntity

func (ECS *ECS) NewEntity(tag string) *Entity

func (*ECS) RegisterEntity

func (ECS *ECS) RegisterEntity(tag string, t reflect.Type, components reflect.Value)

register an entity by adding its type, and components to the ECS

func (*ECS) RegisterSystem

func (ECS *ECS) RegisterSystem(System System)

func (*ECS) SerializeEntity

func (ECS *ECS) SerializeEntity(id uint32) string

serialize an entity by serializing each component TODO make this better, as its gonna be hard to unmarshal the bytes...

func (*ECS) Sys

func (ECS *ECS) Sys() []System

func (*ECS) Update

func (ECS *ECS) Update()

type Empire

type Empire struct {
	*Entity
	*SyncComp
	*PosComp
	*EmpireStatsComp
}

empire entity

type EmpireStatsComp

type EmpireStatsComp struct {
	Name  string
	Money float64
}

component for storing empire statistics

func (*EmpireStatsComp) Deserialize

func (E *EmpireStatsComp) Deserialize(data interface{})

type EmpireStatsEvent

type EmpireStatsEvent struct {
	EventBase
	TargetEmpire   string
	MoneyPerTurnDT float64
}

triggered when something should change the stats of an empire

type EmpireSys

type EmpireSys struct {
	*SystemBase
	PosComps         []*PosComp
	EmpireStatsComps []*EmpireStatsComp
}

empire system

func (*EmpireSys) AddEntity

func (E *EmpireSys) AddEntity(Entity *Entity, PosComp *PosComp, EmpireStatsComp *EmpireStatsComp)

func (*EmpireSys) Close

func (E *EmpireSys) Close()

func (*EmpireSys) Init

func (E *EmpireSys) Init()

func (*EmpireSys) Listen

func (E *EmpireSys) Listen(Event EmpireStatsEvent)

listen out for when something modifies the empires stats

func (*EmpireSys) Remove

func (E *EmpireSys) Remove()

func (*EmpireSys) Update

func (E *EmpireSys) Update()

type Entity

type Entity struct {
	// Unique id for this entity
	ID uint32
	// used to tag the entity with a string identifier
	Tag string
	// used as a util for the ECS
	ComponentCount uint32
}

type Event

type Event interface {
}

type EventBase

type EventBase struct {
}

type GameInterface

type GameInterface struct {
	Server *Server
	Client *Client
}
var (
	Game     *GameInterface
	Username = "default"
)

func (*GameInterface) ProcessClient

func (G *GameInterface) ProcessClient()

func (*GameInterface) ProcessServer

func (G *GameInterface) ProcessServer()

type HealthComponent

type HealthComponent struct {
	Health float64
}

used for anything that has health e.g. units, settlements etc

func (*HealthComponent) Test

func (H *HealthComponent) Test()

type Initialiser

type Initialiser interface {
	Init()
}

type InputData

type InputData struct {
	MouseDepth   int
	MousePressed rune
	MouseHeld    rune
	PrevMouse    rune
	KeyPressed   rune
	KeyHeld      rune
	PrevKey      rune
	// used for special key presses e.g. ctrl + c
	CtrlKeyPressed tcell.Key
	CtrlKeyHeld    tcell.Key
	PrevCtrlKey    tcell.Key
	MousePos       Vec
}

type MovementComp

type MovementComp struct {
	Target Vec
	Speed  float64
}

func (*MovementComp) Test

func (M *MovementComp) Test()

type MovementSys

type MovementSys struct {
	*SystemBase
	// store all the position & movement components components
	PosComps      []*PosComp
	MovementComps []*MovementComp
}

func (*MovementSys) Add

func (MovementSys *MovementSys) Add(Entity *Entity, PosComp *PosComp, MovementComp *MovementComp)

func (*MovementSys) Remove

func (MovementSys *MovementSys) Remove(ECS *ECS)

func (*MovementSys) Update

func (MovementSys *MovementSys) Update()

TODO fix this, we only want to apply the movement on a next turn event

type NetworkSys

type NetworkSys struct {
	*SystemBase
	SyncComps []*SyncComp
	// connection to the server (used if we are a client)
	ServerConnection net.Conn
	// connections to clients (used if we are a server)
	Listener          net.Listener
	ClientConnections map[int]net.Conn
	NumConnections    int
	// address of the server to connect to
	ServerAddress string
}

this system handles everything network related. it can be in 1 of 2 modes, CLIENT or SERVER. the mode determines the behaviour and will send and listen for the relevant events. the system stores all the sync components. these components are sent across the network

func (*NetworkSys) AddEntity

func (N *NetworkSys) AddEntity(Entity *Entity, SyncComp *SyncComp)

func (*NetworkSys) Broadcast

func (N *NetworkSys) Broadcast(command ServerCommandEvent)

func (*NetworkSys) Close

func (N *NetworkSys) Close()

func (*NetworkSys) Direct

func (N *NetworkSys) Direct(clientID int, command ServerCommandEvent)

func (*NetworkSys) Dispatch

func (N *NetworkSys) Dispatch(command ServerCommandEvent)

func (*NetworkSys) Init

func (N *NetworkSys) Init()

func (*NetworkSys) ListenClientCommandEvent

func (N *NetworkSys) ListenClientCommandEvent(command ClientCommandEvent)

TODO CLIENT listen for systems to send commands to the server receive the command, and send it over the connection to the server

func (*NetworkSys) ListenServerCommandEvent

func (N *NetworkSys) ListenServerCommandEvent(command ServerCommandEvent)

TODO CLIENT & SERVER TODO make this code better jesus listen for when the server has done processing and is ready to sync

func (*NetworkSys) PollClientCommands

func (N *NetworkSys) PollClientCommands()

TODO SERVER server listens for commands from clients

func (*NetworkSys) PollClientConnections

func (N *NetworkSys) PollClientConnections()

TODO SERVER listen for client connections. this runs throughout the lifetime of the application

func (*NetworkSys) PollServerCommands

func (N *NetworkSys) PollServerCommands()

TODO CLIENT listen for sync messages from the server connection, once we receive a sync over the network dispatch the sync locally

func (*NetworkSys) Priority

func (N *NetworkSys) Priority() int

the network code must be ran AFTER every other system has updated their state. this allows the server to queue up the changes, and then send them across the network

func (*NetworkSys) Remove

func (N *NetworkSys) Remove()

func (*NetworkSys) Update

func (N *NetworkSys) Update()

type NewWinEvent

type NewWinEvent struct {
	EventBase
	ID    string
	Title string
	Text  map[interface{}]func()
}

event to create a new window

type NextTurnEvent

type NextTurnEvent struct {
	EventBase
	NewTurn uint32
}

type Player

type Player struct {
	*Entity
	*SyncComp
	*PlayerStatsComp
}

player entity

type PlayerStatsComp

type PlayerStatsComp struct {
	// name of the player
	Name string
}

component for storing player info

func (*PlayerStatsComp) Test

func (P *PlayerStatsComp) Test()

type PlayerSys

type PlayerSys struct {
	*SystemBase
	SyncComps        []*SyncComp
	PlayerStatsComps []*PlayerStatsComp
	// the current turn we are on
	Turn       int
	TurnBuffer int
	Done       bool
}

player system

func (*PlayerSys) AddEntity

func (P *PlayerSys) AddEntity(Entity *Entity, PlayerStatsComp *PlayerStatsComp, SyncComp *SyncComp)

func (*PlayerSys) Close

func (P *PlayerSys) Close()

func (*PlayerSys) Init

func (P *PlayerSys) Init()

func (*PlayerSys) ListenServerCommandEvent

func (P *PlayerSys) ListenServerCommandEvent(event ServerCommandEvent)

TODO CLIENT listen for sync event to update our state

func (*PlayerSys) Remove

func (P *PlayerSys) Remove()

func (*PlayerSys) Update

func (P *PlayerSys) Update()

type PosComp

type PosComp struct {
	Pos    Vec
	Facing Vec
	// world or screen
	View uint8
}

func (*PosComp) Test

func (P *PosComp) Test()

type Prioritiser

type Prioritiser interface {
	Priority() int
}

type RenderComp

type RenderComp struct {
	Depth  int
	Offset Vec
	Buffer tcell.CellBuffer
}

func (*RenderComp) Test

func (R *RenderComp) Test()

type RendererSys

type RendererSys struct {
	*SystemBase
	PosComps    []*PosComp
	RenderComps []*RenderComp
	Screen      *Screen
	Clicked     tcell.ButtonMask
}

renderer is a system

func (*RendererSys) AddEntity

func (R *RendererSys) AddEntity(Entity *Entity, RenderComp *RenderComp, PosComp *PosComp)

func (*RendererSys) Close

func (R *RendererSys) Close()

func (*RendererSys) Init

func (R *RendererSys) Init()

func (*RendererSys) Remove

func (R *RendererSys) Remove()

func (*RendererSys) Update

func (R *RendererSys) Update()

type Screen

type Screen struct {
	Screen        tcell.Screen
	Cam           Vec
	Width, Height int
	ZBuffer       []tcell.CellBuffer
	PrevZBuffer   []tcell.CellBuffer
}

func (*Screen) CalculateMouseDepth

func (Screen *Screen) CalculateMouseDepth() int

TODO the screen seems to be able to only recognise clicks on depth 0, every other z-layer is just blank

func (*Screen) Char

func (Screen *Screen) Char(r rune, pos Vec, style tcell.Style, view uint8, depth int)

func (*Screen) Close

func (Screen *Screen) Close()

func (*Screen) Draw

func (Screen *Screen) Draw()

func (*Screen) Init

func (Screen *Screen) Init()

func (*Screen) Poll

func (Screen *Screen) Poll()

func (*Screen) Rect

func (Screen *Screen) Rect(r rune, pos Vec, width, height int, style tcell.Style, fill bool, view uint8, depth int)

func (*Screen) Resize

func (Screen *Screen) Resize()

func (*Screen) ScreenToWorld

func (Screen *Screen) ScreenToWorld(v Vec) Vec

func (*Screen) Text

func (Screen *Screen) Text(text string, pos Vec, style tcell.Style, view uint8, depth int)

TODO We may be able to just write the text directly

func (*Screen) WorldToScreen

func (Screen *Screen) WorldToScreen(v Vec) Vec

type Server

type Server struct {
	ECS *ECS
}

func NewServer

func NewServer() *Server

func (*Server) Close

func (S *Server) Close()

func (*Server) Init

func (S *Server) Init()

func (*Server) Process

func (S *Server) Process()

process all update-able entities

type ServerCommandEvent

type ServerCommandEvent struct {
	EventBase
	// whether the command is on the server or client side
	Side       uint8
	Type       uint32
	Data       []byte
	TargetMode uint8
	Target     int
}

used by clients to send commands to the server

type Settlement

type Settlement struct {
	*Entity
	*SyncComp
	*PosComp
	*SettlementStatsComp
	*RenderComp
}

empire entity

type SettlementStatsComp

type SettlementStatsComp struct {
	Name       string
	Population float64
	Production float64
}

component for storing empire statistics

func (*SettlementStatsComp) Test

func (S *SettlementStatsComp) Test()

type SettlementSys

type SettlementSys struct {
	*SystemBase
	PosComps             []*PosComp
	SettlementStatsComps []*SettlementStatsComp
	SelectedCity         uint32
}

settlement system

func (*SettlementSys) AddEntity

func (S *SettlementSys) AddEntity(Entity *Entity, PosComp *PosComp, SettlementStatsComp *SettlementStatsComp)

func (*SettlementSys) Close

func (S *SettlementSys) Close()

func (*SettlementSys) Init

func (S *SettlementSys) Init()

func (*SettlementSys) ListenClickEvent

func (S *SettlementSys) ListenClickEvent(event ClickEvent)

func (*SettlementSys) Remove

func (S *SettlementSys) Remove()

func (*SettlementSys) Update

func (S *SettlementSys) Update()

type State

type State struct {
	*Entity
	*SyncComp
	*StateComp
}

type StateComp

type StateComp struct {
	PlayerID  string
	Turn      uint32
	TakenTurn bool
}

type StateSys

type StateSys struct {
	*SystemBase
	SyncComps []*SyncComp
	// TODO in theory this should only be a single StateComp
	StateComps []*StateComp
	// the id of the entity that represents us
	OurStateID uint32
}

represents the state of the game it keeps track of the turn etc

func (*StateSys) AddEntity

func (S *StateSys) AddEntity(Entity *Entity, SyncComp *SyncComp, StateComp *StateComp)

func (*StateSys) Init

func (S *StateSys) Init()

func (*StateSys) ListenClientCommandEvent

func (S *StateSys) ListenClientCommandEvent(event ClientCommandEvent)

TODO SERVER server listens for commands

func (*StateSys) ListenServerCommandEvent

func (S *StateSys) ListenServerCommandEvent(event ServerCommandEvent)

func (*StateSys) Remove

func (S *StateSys) Remove()

func (*StateSys) Update

func (S *StateSys) Update()

type SyncAction

type SyncAction struct{}

type SyncComp

type SyncComp struct {
	// this is true if the entity is new or has been modified
	Dirty bool
	// TODO for now we don't need this as the component can simply choose not to deserialize itself
	// names of the components that we DON't want to sync with the server, these will be ignored when syncing.
	// this is particularly useful for ignoring client side components e.g. RenderComps etc
	Hidden map[string]struct{}
}

a sync component is attached to any entity that needs to be synchronized on the network

type SyncComponentContainer

type SyncComponentContainer struct {
	Id   string
	Data string
}

type SyncEntityContainer

type SyncEntityContainer struct {
	Id         float64
	Tag        string
	Components []SyncComponentContainer
}

type System

type System interface {
	// update called every frame
	Update()
	Remove()
}

type SystemBase

type SystemBase struct {
	ECS      *ECS
	Entities []*Entity
	Size     int
	Priority int
}

func NewSysBase

func NewSysBase(ECS *ECS) *SystemBase

type Text

type Text struct {
	UITemplate
	// the text is an interface so it can be updated on the fly
	T interface{}
	// if T is a pointer to a value
	Ptr      bool
	Pos      Vec
	Callback Callback
}

func (*Text) Draw

func (Text *Text) Draw()

type Transform

type Transform struct {
	P Vec
	R Vec
}

type UI

type UI interface {
	Draw()
}

type UIManager

type UIManager struct {
	Screen *Screen
	// TODO optimise this by using a uint32 id
	UI map[string]UI
}

func NewUIManager

func NewUIManager(Screen *Screen) *UIManager

func (*UIManager) AddUI

func (UIManager *UIManager) AddUI(id string, ui UI)

func (*UIManager) Draw

func (UIManager *UIManager) Draw()

func (*UIManager) GetText

func (UIManager *UIManager) GetText(id string) *Text

set the T value of a text UI element

func (*UIManager) NewText

func (UIManager *UIManager) NewText(id, text string, enabled bool, pos Vec, view uint8, style tcell.Style, callback Callback) *Text

func (*UIManager) NewWin

func (UIManager *UIManager) NewWin(id string, enabled bool, pos Vec) *Window

func (*UIManager) Remove

func (U *UIManager) Remove(id string)

func (*UIManager) SetText

func (UIManager *UIManager) SetText(id, text string)

set the T value of a text UI element

func (*UIManager) SetWinText

func (UIManager *UIManager) SetWinText(winID, id, text string)

set the T value of a text UI element

func (*UIManager) WinRemoveText

func (UIManager *UIManager) WinRemoveText(id string, textIDs ...string)

set the T value of a text UI element

type UISys

type UISys struct {
	*SystemBase
	UIManager *UIManager
}

TODO this is to test a UI system

func (*UISys) ListenDestroyWinEvent

func (U *UISys) ListenDestroyWinEvent()

func (*UISys) ListenNewWinEvent

func (U *UISys) ListenNewWinEvent(event NewWinEvent)

func (*UISys) ListenNextTurnEvent

func (U *UISys) ListenNextTurnEvent(event NextTurnEvent)

func (*UISys) Priority

func (U *UISys) Priority() int

func (*UISys) Remove

func (U *UISys) Remove()

func (*UISys) Update

func (U *UISys) Update()

type UITemplate

type UITemplate struct {
	UIManager *UIManager
	ID        string
	Enabled   bool
	View      uint8
	Style     tcell.Style
}

func (*UITemplate) Enable

func (UITemplate *UITemplate) Enable(enabled bool)

type UnitSys

type UnitSys struct {
	*SystemBase
	SyncComps     []*SyncComp
	PosComps      []*PosComp
	MovementComps []*MovementComp
	HealthComps   []*HealthComponent
	AttackComps   []*AttackComponent
	SelectedUnit  uint32
}

func (*UnitSys) AddEntity

func (U *UnitSys) AddEntity(Entity *Entity, SyncComp *SyncComp, PosComp *PosComp, MovementComp *MovementComp, HealthComp *HealthComponent, AttackComp *AttackComponent)

func (*UnitSys) Init

func (U *UnitSys) Init()

func (*UnitSys) ListenClickEvent

func (U *UnitSys) ListenClickEvent(event ClickEvent)

func (*UnitSys) ListenClientCommandEvent

func (U *UnitSys) ListenClientCommandEvent(event ClientCommandEvent)

TODO SERVER listen for when the player wants to move a unit

func (*UnitSys) Remove

func (U *UnitSys) Remove()

func (*UnitSys) Update

func (U *UnitSys) Update()

type Vec

type Vec struct {
	X, Y, Z, W float64
}

func Dir

func Dir(v1, v2 Vec) Vec

func Lerp

func Lerp(v1, v2 Vec, intensity float64) Vec

func V2

func V2(x, y float64) Vec

func V2i

func V2i(x, y int) Vec

func V3

func V3(x, y, z float64) Vec

func V4

func V4(x, y, z, w float64) Vec

func (Vec) Add

func (v Vec) Add(other interface{}) Vec

func (Vec) Div

func (v Vec) Div(other interface{}) Vec

func (Vec) Equals

func (v Vec) Equals(other Vec) bool

func (Vec) Mag

func (v Vec) Mag() float64

func (Vec) Mul

func (v Vec) Mul(other interface{}) Vec

func (Vec) Normalize

func (v Vec) Normalize() Vec

func (Vec) Round

func (v Vec) Round() Vec

func (Vec) Sub

func (v Vec) Sub(other interface{}) Vec

type Window

type Window struct {
	UITemplate
	Title      string
	Pos, Size  Vec
	Text       []*Text
	Dragging   bool
	DragOffset Vec
}

func (*Window) Draw

func (Window *Window) Draw()

func (*Window) NewText

func (Window *Window) NewText(id string, text interface{}, style tcell.Style, callback Callback)

the reason the text is an interface, is becuase it can be any value and thus be updated on the fly

func (*Window) RemoveText

func (Window *Window) RemoveText(textIDs ...string)

func (*Window) UpdateSize

func (Window *Window) UpdateSize()

update the size of the window based on the text contents

func (*Window) UpdateTextPos

func (Window *Window) UpdateTextPos()

func (*Window) WinGetElem

func (Window *Window) WinGetElem(id string) *Text

type WorldSys

type WorldSys struct {
	*SystemBase
	CellDatComps []*CellDatComp
	// position of cells
	PosComps      []*PosComp
	Width, Height int
}

func (*WorldSys) AddEntity

func (W *WorldSys) AddEntity(Entity *Entity, CellDatComp *CellDatComp, PosComp *PosComp)

func (*WorldSys) Init

func (W *WorldSys) Init()

func (*WorldSys) ListenClickEvent

func (W *WorldSys) ListenClickEvent(event ClickEvent)

func (*WorldSys) Priority

func (W *WorldSys) Priority() int

low priority as we want to render last

func (*WorldSys) Remove

func (W *WorldSys) Remove()

func (*WorldSys) Update

func (W *WorldSys) Update()

Jump to

Keyboard shortcuts

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