room

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args struct {
	Id   int
	Info *Info
}

Args hold the arguments for room events.

type ChatType

type ChatType int
const (
	Talk ChatType = iota + 1
	Whisper
	Shout
)

type EntitiesArgs

type EntitiesArgs struct {
	Entered  bool
	Entities []Entity
}

EntitiesArgs holds the arguments for events involving a list of entities.

type Entity

type Entity struct {
	EntityBase
	Dir     int
	HeadDir int
	Action  string
}

Entity represents a user, pet or bot in a room.

func (*Entity) Compose added in v0.1.2

func (ent *Entity) Compose(p *g.Packet, pos *int)

func (*Entity) Parse added in v0.1.2

func (ent *Entity) Parse(p *g.Packet, pos *int)

func (Entity) String added in v0.2.4

func (ent Entity) String() string

type EntityArgs

type EntityArgs struct {
	Entity Entity
}

EntityArgs holds the arguments for events involving a single entity.

type EntityBase added in v0.1.2

type EntityBase struct {
	Index  int
	Name   string
	Figure string
	Gender string
	Custom string
	Tile
	PoolFigure string
	BadgeCode  string
	Type       EntityType
}

type EntityChatArgs

type EntityChatArgs struct {
	EntityArgs
	Type    ChatType
	Message string
}

EntityChat holds the arguments for chat events.

type EntityStatus added in v0.1.2

type EntityStatus struct {
	Index int
	Tile
	HeadDir, BodyDir int
	Action           string
}

EntityStatus represents a status update of an entity in a room.

type EntityType

type EntityType int
const (
	User EntityType = iota + 1
	Pet
	PublicBot
	PrivateBot
)

func (EntityType) Compose added in v0.2.4

func (entityType EntityType) Compose(p *g.Packet, pos *int)

func (*EntityType) Parse

func (entityType *EntityType) Parse(p *g.Packet, pos *int)

func (EntityType) String added in v0.2.4

func (entityType EntityType) String() string

type EntityUpdateArgs added in v0.1.2

type EntityUpdateArgs struct {
	Pre    Entity // Prev is the previous state of the entity before the update.
	Entity Entity // Cur is the current state of the entity after the update.
}

EntityUpdateArgs holds the arguments for entity update events.

type Info

type Info struct {
	CanOthersMoveFurni  bool
	Door                int
	Id                  int
	Owner               string
	Marker              string
	Name                string
	Description         string
	ShowOwnerName       bool
	Trading             int
	Alert               int
	MaxVisitors         int
	AbsoluteMaxVisitors int
}

Info contains information about a room.

type Item

type Item struct {
	Id       int
	Class    string
	Owner    string
	Location string
	Type     string
}

Item represents a wall item in a room.

func (*Item) Parse

func (item *Item) Parse(p *g.Packet, pos *int)

func (*Item) ParseString added in v0.2.0

func (item *Item) ParseString(s string)

func (Item) String added in v0.2.4

func (item Item) String() string

type ItemArgs

type ItemArgs struct {
	Item Item
}

ItemArgs holds the arguments for wall item events involing a single item.

type ItemUpdateArgs added in v0.2.6

type ItemUpdateArgs struct {
	Pre  Item // Pre is the previous state of the item before the update.
	Item Item // Item is the current state of the item after the update.
}

ItemUpdateArgs holds the arguments for wall item update events.

type Items

type Items []Item

func (*Items) Parse

func (items *Items) Parse(p *g.Packet, pos *int)

type ItemsArgs

type ItemsArgs struct {
	Items []Item
}

ItemsArgs holds the arguments for wall item events involing a list of items.

type Manager

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

func NewManager

func NewManager(ix g.Interceptor) *Manager

func (*Manager) Entered

func (mgr *Manager) Entered(handler g.EventHandler[Args])

Entered registers an event handler that is invoked when the user enters a room.

func (*Manager) Entities

func (mgr *Manager) Entities(yield func(ent Entity) bool)

Entities iterates over all entities currently in the room.

func (*Manager) EntitiesAdded

func (mgr *Manager) EntitiesAdded(handler g.EventHandler[EntitiesArgs])

EntitiesAdded registers an event handler that is invoked when entities are loaded or enter the room. The Entered flag on the EntitiesArgs indicates whether the entity entered the room. If not, the entities were already in the room and are being loaded.

func (*Manager) Entity added in v0.3.0

func (mgr *Manager) Entity(id int) *Entity

Entity gets an entity in the room by its index. It returns nil if the entity was not found.

func (*Manager) EntityByName added in v0.2.1

func (mgr *Manager) EntityByName(name string) *Entity

EntityByName gets the entity with the specified name. Names are case-insensitive. Returns nil if it does not exist.

func (*Manager) EntityChat

func (mgr *Manager) EntityChat(handler g.EventHandler[EntityChatArgs])

EntityChat registers an event handler that is invoked when an entity sends a chat message.

func (*Manager) EntityCount added in v0.3.0

func (mgr *Manager) EntityCount() int

EntityCount returns the number of entities in the room.

func (*Manager) EntityLeft

func (mgr *Manager) EntityLeft(handler g.EventHandler[EntityArgs])

EntityLeft registers an event handler that is invoked when an entity leaves the room.

func (*Manager) EntityUpdated added in v0.1.2

func (mgr *Manager) EntityUpdated(handler g.EventHandler[EntityUpdateArgs])

func (*Manager) HasRights added in v0.1.5

func (mgr *Manager) HasRights() bool

func (*Manager) Heightmap

func (mgr *Manager) Heightmap() []string

func (*Manager) Id added in v0.3.0

func (mgr *Manager) Id() int

func (*Manager) Info added in v0.3.0

func (mgr *Manager) Info() *Info

func (*Manager) IsInRoom

func (mgr *Manager) IsInRoom() bool

func (*Manager) IsOwner added in v0.1.5

func (mgr *Manager) IsOwner() bool

func (*Manager) Item added in v0.3.0

func (mgr *Manager) Item(id int) *Item

Item gets a wall item in the room by its ID. It returns nil if the item was not found.

func (*Manager) ItemAdded added in v0.2.0

func (mgr *Manager) ItemAdded(handler g.EventHandler[ItemArgs])

ItemAdded registers an event handler that is invoked when a wall item is added to the room.

func (*Manager) ItemCount added in v0.3.0

func (mgr *Manager) ItemCount() int

ItemCount returns the number of items in the room.

func (*Manager) ItemRemoved

func (mgr *Manager) ItemRemoved(handler g.EventHandler[ItemArgs])

ItemRemoved registers an event handler that is invoked when an item is removed from the room.

func (*Manager) ItemUpdated added in v0.2.6

func (mgr *Manager) ItemUpdated(handler g.EventHandler[ItemUpdateArgs])

ItemUpdated registers an event handler that is invoked when a wall item is updated in the room.

func (*Manager) Items

func (mgr *Manager) Items(yield func(item Item) bool)

Items iterates over all wall items currently in the room.

func (*Manager) ItemsLoaded added in v0.2.0

func (mgr *Manager) ItemsLoaded(handler g.EventHandler[ItemsArgs])

ItemsLoaded registers an event handler that is invoked when wall items are loaded.

func (*Manager) Left

func (mgr *Manager) Left(handler g.EventHandler[Args])

Left registers an event handler that is invoked when the user leaves the room.

func (*Manager) Model added in v0.3.0

func (mgr *Manager) Model() string

func (*Manager) Object added in v0.3.0

func (mgr *Manager) Object(id int) *Object

Object gets a floor item in the room by its ID. It returns nil if the object was not found.

func (*Manager) ObjectAdded

func (mgr *Manager) ObjectAdded(handler g.EventHandler[ObjectArgs])

ObjectAdded registers an event handler that is invoked when a floor item is added to the room.

func (*Manager) ObjectCount added in v0.3.0

func (mgr *Manager) ObjectCount() int

ObjectCount returns the number of objects in the room.

func (*Manager) ObjectRemoved

func (mgr *Manager) ObjectRemoved(handler g.EventHandler[ObjectArgs])

ObjectRemoved registers an event handler that is invoked when a floor item is removed from the room.

func (*Manager) ObjectUpdated added in v0.1.2

func (mgr *Manager) ObjectUpdated(handler g.EventHandler[ObjectUpdateArgs])

ObjectUpdated registers an event handler that is invoked when a floor item is updated in the room.

func (*Manager) Objects

func (mgr *Manager) Objects(yield func(obj Object) bool)

Objects iterates over all floor items currently in the room.

func (*Manager) ObjectsLoaded

func (mgr *Manager) ObjectsLoaded(handler g.EventHandler[ObjectsArgs])

ObjectsLoaded registers an event handler that is invoked when floor items are loaded.

func (*Manager) RightsUpdated added in v0.1.5

func (mgr *Manager) RightsUpdated(handler g.VoidHandler)

func (*Manager) Slide added in v0.2.4

func (mgr *Manager) Slide(handler g.EventHandler[SlideArgs])

Slide registers an event handler that is invoked when floor items or an entity slides, e.g. along a roller.

type Object

type Object struct {
	Id            int
	Class         string
	X, Y          int
	Width, Height int
	Direction     int
	Z             float64
	Colors        string
	RuntimeData   string
	Extra         int
	StuffData     string
}

Object represents a floor item in a room.

func (*Object) Parse added in v0.2.4

func (obj *Object) Parse(p *g.Packet, pos *int)

func (Object) String added in v0.2.4

func (obj Object) String() string

type ObjectArgs

type ObjectArgs struct {
	Object Object
}

ObjectArgs holds the arguments for floor item events involving a single item.

type ObjectUpdateArgs added in v0.1.2

type ObjectUpdateArgs struct {
	Pre    Object // Prev is the previous state of the object before the update.
	Object Object // Cur is the current state of the object after the update.
}

ObjectUpdateArgs holds the arguments for floor item update events.

type ObjectsArgs

type ObjectsArgs struct {
	Objects []Object
}

ObjectArgs holds the arguments for floor item events involving a list of items.

type Point added in v0.2.4

type Point struct {
	X, Y int
}

Point represents 2-dimensional coordinates in a room.

func (Point) String added in v0.2.4

func (pt Point) String() string

func (Point) ToTile added in v0.2.4

func (pt Point) ToTile() Tile

ToTile converts the Point to a Tile with Z = 0.

type SlideArgs added in v0.2.4

type SlideArgs struct {
	From, To     Point
	ObjectSlides []SlideObjectArgs
	// Source contains the object that caused the slide, if it is available.
	Source        *Object
	SlideMoveType SlideMoveType
	// EntitySlide contains arguments for an entity slide event, if an entity is involved in this event.
	EntitySlide *SlideEntityArgs
}

SlideArgs holds the arguments for floor item and entity slide events.

type SlideEntityArgs added in v0.2.4

type SlideEntityArgs struct {
	// Entity contains the state of the entity after the slide update.
	Entity   Entity
	From, To Tile
}

type SlideMoveType added in v0.2.4

type SlideMoveType int
const (
	SlideMoveTypeNone SlideMoveType = iota
	SlideMoveTypeMove
	SlideMoveTypeSlide
)

func (*SlideMoveType) Parse added in v0.2.4

func (slideType *SlideMoveType) Parse(p *g.Packet, pos *int)

type SlideObject added in v0.2.4

type SlideObject struct {
	Id         int
	FromZ, ToZ float64
}

type SlideObjectArgs added in v0.2.4

type SlideObjectArgs struct {
	// Object contains the state of the object after the slide update.
	Object   Object
	From, To Tile
}

SlideObjectArgs holds the arguments for floor item slide events.

type SlideObjectBundle added in v0.2.4

type SlideObjectBundle struct {
	From, To      Point
	Objects       []SlideObject
	RollerId      int
	SlideMoveType SlideMoveType
	Entity        SlideObject
}

func (*SlideObjectBundle) Parse added in v0.2.4

func (bundle *SlideObjectBundle) Parse(p *g.Packet, pos *int)

type Tile added in v0.1.2

type Tile struct {
	X, Y int
	Z    float64
}

Tile represents 3-dimensional coordinates in a room.

func (Tile) String added in v0.2.4

func (tile Tile) String() string

func (Tile) ToPoint added in v0.2.4

func (tile Tile) ToPoint() Point

ToPoint converts the Tile to a Point.

Jump to

Keyboard shortcuts

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