Documentation ¶
Index ¶
- Constants
- Variables
- func EachChunkNearby(wc coords.World, cb func(cc coords.Chunk, priority int))
- func EveryItem() chan Item
- type Biotic
- type BioticListener
- type BioticState
- type BlockListener
- type ChunkGenerationResult
- type ChunkGenerator
- type ChunkListener
- type ChunkStatus
- type ControlState
- type Damageable
- type Entity
- type EntityId
- type EntityKind
- type EntityState
- type Health
- type HistoryBuffer
- type HistoryEntry
- type Inventory
- func (inv *Inventory) AddItem(item Item) bool
- func (inv *Inventory) ItemsToByteArray() []byte
- func (inv *Inventory) LeftItem() Item
- func (inv *Inventory) MoveItems(from, to int)
- func (inv *Inventory) RemoveItem(item Item) bool
- func (inv *Inventory) RightItem() Item
- func (inv *Inventory) SetActiveItems(left, right int)
- type Item
- type Player
- func (p *Player) Body() physics.Body
- func (p *Player) BoxAt(t float64) *physics.Box
- func (p *Player) ClientInventoryUpdated()
- func (p *Player) ClientTick(controls ControlState) *coords.World
- func (p *Player) Collects() bool
- func (p *Player) Damage(amount int)
- func (p *Player) Dead() bool
- func (p *Player) EntityId() EntityId
- func (p *Player) Give(item Item) bool
- func (p *Player) Inventory() *Inventory
- func (p *Player) LastUpdated() float64
- func (p *Player) Life() int
- func (p *Player) Look() coords.Direction
- func (p *Player) NeedsInventoryUpdate() bool
- func (p *Player) Respawn(pos coords.World)
- func (p *Player) State() *BioticState
- func (p *Player) Take(item Item) bool
- func (p *Player) Wpos() coords.World
- type Possessor
- type Respawnable
- type Stack
- type State
- type World
- func (w *World) AddBioticListener(listener BioticListener)
- func (w *World) AddBlockListener(listener BlockListener)
- func (w *World) AddChunkListener(listener ChunkListener)
- func (w *World) AddEntity(e Entity)
- func (w *World) AddWorldItemListener(listener WorldItemListener)
- func (w *World) Biotics() map[EntityId]Biotic
- func (w *World) Block(bc coords.Block) mapgen.Block
- func (w *World) ChangeBlock(bc coords.Block, newBlock mapgen.Block)
- func (w *World) Chunk(cc coords.Chunk) *mapgen.Chunk
- func (w *World) DamageBiotic(damager string, amount int, s Biotic)
- func (w *World) FindFirstIntersect(entity Biotic, t float64, ray *physics.Ray) (*coords.World, Biotic)
- func (w *World) FireBioticUpdated(id EntityId, biotic Biotic)
- func (w *World) RemoveBioticListener(listener BioticListener)
- func (w *World) RemoveBlockListener(listener BlockListener)
- func (w *World) RemoveChunkListener(listener ChunkListener)
- func (w *World) RemoveEntity(e Entity)
- func (w *World) RemoveWorldItemListener(listener WorldItemListener)
- func (w *World) Tick(dt int64)
- func (w *World) WorldItems() map[EntityId]*WorldItem
- type WorldItem
- func (wi *WorldItem) Body() physics.Body
- func (wi *WorldItem) BoxAt(t float64) *physics.Box
- func (wi *WorldItem) EntityId() EntityId
- func (wi *WorldItem) LastUpdated() float64
- func (wi *WorldItem) Look() coords.Direction
- func (wi *WorldItem) State() *WorldItemState
- func (wi *WorldItem) Tick(dt int64, w *World) (bool, bool)
- func (wi *WorldItem) Wpos() coords.World
- type WorldItemListener
- type WorldItemState
Constants ¶
View Source
const ( EntityKindPlayer = EntityKind(iota) EntityKindBiotic EntityKindWorldItem )
View Source
const ( INV_WIDTH = 5 INV_HEIGHT = 5 MAX_STACK = 50 )
View Source
const ( ITEM_NIL = Item(iota) ITEM_DIRT ITEM_STONE ITEM_SHOVEL ITEM_GUN ITEM_SPAWN ITEM_GRASS ITEM_COAL ITEM_IRON ITEM_GOLD ITEM_SAPPHIRE ITEM_EMERALD ITEM_RUBY ITEM_DIAMOND ITEM_POUDRETTEITE ITEM_GLASS // Keep this last TOTAL_ITEMS )
View Source
const ( // Properties STACKABLE = 0x1 << iota SHOOTABLE )
Variables ¶
View Source
var ITEM_PROPERTIES []uint32 = []uint32{ 0, STACKABLE, STACKABLE, 0, SHOOTABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, STACKABLE, }
View Source
var PLAYER_MAX_LIFE = 100
Gameplay state defaults
View Source
var PlayerCenterOffset = vmath.Vec3{
0,
playerHeight/2 - playerEyeHeight,
0,
}
View Source
var PlayerHalfExtents = vmath.Vec3{
0.4,
playerHeight / 2,
0.4,
}
Functions ¶
func EachChunkNearby ¶
Types ¶
type Biotic ¶
type Biotic interface { Entity Damageable Respawnable State() *BioticState }
type BioticListener ¶
type BioticState ¶
type BioticState struct { EntityState EntityState Health Health }
type BlockListener ¶
type ChunkGenerationResult ¶
type ChunkGenerationResult struct {
// contains filtered or unexported fields
}
type ChunkGenerator ¶
type ChunkGenerator struct { // Chunks are sent to this channel as they are generated Generated chan ChunkGenerationResult // contains filtered or unexported fields }
func NewChunkGenerator ¶
func NewChunkGenerator(generator mapgen.Generator) *ChunkGenerator
func (*ChunkGenerator) QueueChunksNearby ¶
func (cm *ChunkGenerator) QueueChunksNearby(wc coords.World)
func (*ChunkGenerator) Run ¶
func (cm *ChunkGenerator) Run()
type ChunkListener ¶
type ChunkStatus ¶
type ChunkStatus struct {
// contains filtered or unexported fields
}
type ControlState ¶
type ControlState struct { ControlFlags int Lat float64 Lon float64 // JavaScript performance.now() timestamp. // TimeStamp is when it was sent, ViewTimestamp is // what time the client was displaying when it was sent // (with lag induction they may differ). Timestamp float64 // In ms ViewTimestamp float64 }
func (*ControlState) ActivateLeft ¶
func (cs *ControlState) ActivateLeft() bool
func (*ControlState) ActivateRight ¶
func (cs *ControlState) ActivateRight() bool
func (*ControlState) Back ¶
func (cs *ControlState) Back() bool
func (*ControlState) Forward ¶
func (cs *ControlState) Forward() bool
func (*ControlState) Jump ¶
func (cs *ControlState) Jump() bool
func (*ControlState) Left ¶
func (cs *ControlState) Left() bool
func (*ControlState) Right ¶
func (cs *ControlState) Right() bool
type Damageable ¶
type EntityKind ¶
type EntityKind byte
type EntityState ¶
func (*EntityState) Look ¶
func (es *EntityState) Look() coords.Direction
func (*EntityState) Wpos ¶
func (es *EntityState) Wpos() coords.World
type HistoryBuffer ¶
type HistoryBuffer struct {
// contains filtered or unexported fields
}
func NewHistoryBuffer ¶
func NewHistoryBuffer() *HistoryBuffer
func (*HistoryBuffer) BodyAt ¶
func (ph *HistoryBuffer) BodyAt(t float64) *physics.Body
If t > most recent time added, return most recent position added. If t < ring buffer history, return oldest position stored. If t == an entry in the ring buffer, return that entry. If t is between two entries in the ring buffer, interpolate between them.
func (*HistoryBuffer) Clear ¶
func (ph *HistoryBuffer) Clear()
type HistoryEntry ¶
type HistoryEntry struct {
// contains filtered or unexported fields
}
type Inventory ¶
type Inventory struct {
// contains filtered or unexported fields
}
func NewInventory ¶
func NewInventory() *Inventory
func (*Inventory) AddItem ¶
Adds an item to the inventory. Returns true if the addition was successful, false if there is no room remaining in the inventory.
func (*Inventory) ItemsToByteArray ¶
func (*Inventory) RemoveItem ¶
Removes an item from the inventory. Returns true if the removal was successful, false if the given item does not exist in the inventory.
func (*Inventory) SetActiveItems ¶
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
func (*Player) ClientInventoryUpdated ¶
func (p *Player) ClientInventoryUpdated()
func (*Player) ClientTick ¶
func (p *Player) ClientTick(controls ControlState) *coords.World
func (*Player) LastUpdated ¶
Returns the last time this entity's state was updated (i.e. by a client sending a control-state packet).
func (*Player) NeedsInventoryUpdate ¶
func (*Player) State ¶
func (p *Player) State() *BioticState
type Respawnable ¶
type World ¶
type World struct {
// contains filtered or unexported fields
}
func (*World) AddBioticListener ¶
func (w *World) AddBioticListener(listener BioticListener)
func (*World) AddBlockListener ¶
func (w *World) AddBlockListener(listener BlockListener)
func (*World) AddChunkListener ¶
func (w *World) AddChunkListener(listener ChunkListener)
func (*World) AddWorldItemListener ¶
func (w *World) AddWorldItemListener(listener WorldItemListener)
func (*World) FindFirstIntersect ¶
func (*World) FireBioticUpdated ¶
func (*World) RemoveBioticListener ¶
func (w *World) RemoveBioticListener(listener BioticListener)
func (*World) RemoveBlockListener ¶
func (w *World) RemoveBlockListener(listener BlockListener)
func (*World) RemoveChunkListener ¶
func (w *World) RemoveChunkListener(listener ChunkListener)
func (*World) RemoveEntity ¶
func (*World) RemoveWorldItemListener ¶
func (w *World) RemoveWorldItemListener(listener WorldItemListener)
func (*World) WorldItems ¶
type WorldItem ¶
type WorldItem struct {
// contains filtered or unexported fields
}
func (*WorldItem) LastUpdated ¶
func (*WorldItem) State ¶
func (wi *WorldItem) State() *WorldItemState
type WorldItemListener ¶
type WorldItemState ¶
type WorldItemState struct { EntityState EntityState ItemKind Item }
Click to show internal directories.
Click to hide internal directories.