sendtables

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 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. Returns nil if the property wasn't found. Panics if more than one property with the same name was found.

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 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 (*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 SendTableParser added in v0.4.0

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

SendTableParser provides functions for parsing send-tables.

func (*SendTableParser) ClassBits added in v0.4.0

func (p *SendTableParser) ClassBits() int

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

func (*SendTableParser) FindServerClassByName added in v0.4.0

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

FindServerClassByName finds and returns a server-class by it's name. Returns nil if the server-class wasn't found. Panics if more than one server-class with the same name was found.

func (*SendTableParser) ParsePacket added in v0.4.0

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

ParsePacket parses a send-table packet.

func (*SendTableParser) ServerClasses added in v0.4.0

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

ServerClasses returns the parsed server-classes

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.

Jump to

Keyboard shortcuts

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