sendtables

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sendtables contains sendtable specific magic and should really be better documented (TODO).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	ID          int
	ServerClass *ServerClass
	// contains filtered or unexported fields
}

Entity stores a entity in the game (e.g. players etc.) with its properties.

func NewEntity

func NewEntity(id int, serverClass *ServerClass) *Entity

NewEntity creates a new Entity with a given id and ServerClass and returns it.

func (*Entity) ApplyUpdate

func (e *Entity) ApplyUpdate(reader *bit.BitReader)

ApplyUpdate reads an update to an Enitiy's properties and triggers registered PropertyUpdateHandlers if values changed.

func (*Entity) CollectProperties

func (e *Entity) CollectProperties(ppBase *map[int]PropValue)

CollectProperties registers PropertyUpdateHandlers on the Entitiy that will update a 'preprocessedBasleine' map with the most recent values. This is used if entities leave and re-enter the PVS as entities will be re-created at that point and we can then take the map as baseline for the new entity.

func (*Entity) FindProperty

func (e *Entity) FindProperty(name string) *PropertyEntry

FindProperty finds a property on the Entity by name.

func (*Entity) Props

func (e *Entity) Props() []PropertyEntry

Props returns all properties (PropertyEntry) for the Entity.

type EntityCreatedEvent

type EntityCreatedEvent struct {
	ServerClass *ServerClass
	Entity      *Entity
}

EntityCreatedEvent contains information about a newly created entity.

type EntityCreatedHandler

type EntityCreatedHandler func(EntityCreatedEvent)

EntityCreatedHandler is the interface for handlers that are interested in EntityCreatedEvents.

type FlattenedPropEntry

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

FlattenedPropEntry stores meta information about a property of an Entity.

func (FlattenedPropEntry) Name

func (fpe FlattenedPropEntry) Name() string

Name returs the name of the prop entry.

type Parser

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

Parser provides functions for parsing send-tables.

func (*Parser) ClassBits

func (p *Parser) ClassBits() int

ClassBits seems to calculate how many bits must be read for the server-class ID. Not 100% sure how tho tbh.

func (*Parser) FindServerClassByName

func (p *Parser) FindServerClassByName(name string) *ServerClass

FindServerClassByName finds and returns a server-class by it's name.

func (*Parser) ParsePacket

func (p *Parser) ParsePacket(r *bit.BitReader)

ParsePacket parses a send-table packet.

func (*Parser) ServerClasses

func (p *Parser) ServerClasses() []*ServerClass

ServerClasses returns the parsed server-classes

type PropValue

type PropValue struct {
	VectorVal r3.Vector
	IntVal    int
	ArrayVal  []PropValue
	StringVal string
	FloatVal  float32
}

PropValue stores parsed & decoded send-table values. For instance player health, location etc.

type PropertyEntry

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

PropertyEntry wraps a FlattenedPropEntry and allows registering handlers that can be triggered on a update of the property.

func NewPropertyEntry

func NewPropertyEntry(entry *FlattenedPropEntry, index int) PropertyEntry

NewPropertyEntry creates a new PropertyEntry from a FlattenedPropEntry and index

func (*PropertyEntry) Entry

func (pe *PropertyEntry) Entry() *FlattenedPropEntry

Entry returns the underlying FlattenedPropEntry.

func (*PropertyEntry) FirePropertyUpdate

func (pe *PropertyEntry) FirePropertyUpdate(value PropValue)

FirePropertyUpdate triggers all registered PropertyUpdateHandler on the PropertyEntry with the given PropValue.

func (*PropertyEntry) RegisterPropertyUpdateHandler

func (pe *PropertyEntry) RegisterPropertyUpdateHandler(handler PropertyUpdateHandler)

RegisterPropertyUpdateHandler registers a PropertyUpdateHandler. The handler will be triggered on every FirePropertyUpdate call.

type PropertyUpdateHandler

type PropertyUpdateHandler func(PropValue)

PropertyUpdateHandler is the interface for handlers that are interested in PropertyEntry changes.

type ServerClass

type ServerClass struct {
	ClassID        int
	DataTableID    int
	Name           string
	DTName         string
	FlattenedProps []FlattenedPropEntry
	BaseClasses    []*ServerClass
	// contains filtered or unexported fields
}

ServerClass stores meta information about Entity types (e.g. palyers, teams etc.).

func (*ServerClass) FireEntityCreatedEvent

func (sc *ServerClass) FireEntityCreatedEvent(entity *Entity)

FireEntityCreatedEvent triggers all registered EntityCreatedHandlers on the ServerClass with a new EntityCreatedEvent.

func (*ServerClass) RegisterEntityCreatedHandler

func (sc *ServerClass) RegisterEntityCreatedHandler(handler EntityCreatedHandler)

RegisterEntityCreatedHandler registers a EntityCreatedHandler on the ServerClass. The handler will be triggered on every FireEntityCreatedEvent call.

func (*ServerClass) String

func (sc *ServerClass) String() string

String returns a human readable identification of the ServerClass.

Jump to

Keyboard shortcuts

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