Documentation
¶
Index ¶
- Constants
- func AddToQueue(e Event, priority ...int)
- func ClearListeners()
- func GetLogger() eventLogger
- func ProcessEvents()
- func SetDebug(on bool)
- func UnregisterListener(emptyEvent Event, id ListenerId) bool
- type Broadcast
- type Buff
- type BuffsTriggered
- type CharacterChanged
- type CharacterCreated
- type CharacterStatsChanged
- type CharacterTrained
- type CharacterVitalsChanged
- type Communication
- type DayNightCycle
- type EquipmentChange
- type Event
- type EventFlag
- type EventType
- type GainExperience
- type GenericEvent
- type Input
- type ItemOwnership
- type LevelUp
- type Listener
- type ListenerId
- type ListenerReturn
- type ListenerWrapper
- type Log
- type Looking
- type MSP
- type Message
- type MobDeath
- type MobIdle
- type NewRound
- type NewTurn
- type Party
- type PartyUpdated
- type PlayerDeath
- type PlayerDespawn
- type PlayerDrop
- type PlayerSpawn
- type Quest
- type Queue
- type QueueFlag
- type RebuildMap
- type RedrawPrompt
- type RoomAction
- type RoomChange
- type ScriptedEvent
- type System
- type UserSettingChanged
- type WebClientCommand
Constants ¶
const ( NoListenerSampleSize = 20 First QueueFlag = 1 Last QueueFlag = 2 // // Event return codes // // Allows the event to continu to the next listener Continue ListenerReturn = 0b00000001 // Cancels any further processing of the event Cancel ListenerReturn = 0b00000010 // Cancels processing, but adds back into the queue for the next event loop. CancelAndRequeue ListenerReturn = 0b00000100 )
Variables ¶
This section is empty.
Functions ¶
func AddToQueue ¶
Enqueue adds an event to the global queue. The caller can optionally pass a priority value. If omitted, the default priority is 0.
func ClearListeners ¶
func ClearListeners()
func ProcessEvents ¶
func ProcessEvents()
ProcessEvents runs the event loop until the queue is empty. It processes events one at a time in order of priority. Any events enqueued (even from within a handler) will be picked up in order.
func UnregisterListener ¶
func UnregisterListener(emptyEvent Event, id ListenerId) bool
Returns true if listener found and removed.
Types ¶
type Broadcast ¶
type Broadcast struct { Text string TextScreenReader string // optional text for screenreader friendliness IsCommunication bool SourceIsMod bool SkipLineRefresh bool }
Messages that are intended to reach all users on the system
type Buff ¶
type Buff struct { UserId int MobInstanceId int BuffId int Source string // optional source such as spell, }
EVENT DEFINITIONS FOLLOW NOTE: If you give an event the following receiver function: `UniqueID() string`
It will become a "unique event", meaning only one can be in the event queue at a time matching the string return value. Example: See `RedrawPrompt`
Used to apply or remove buffs
type BuffsTriggered ¶
func (BuffsTriggered) Type ¶
func (b BuffsTriggered) Type() string
type CharacterChanged ¶
Fired when a character alt change has occured.
func (CharacterChanged) Type ¶
func (p CharacterChanged) Type() string
type CharacterCreated ¶
Fired after creating a new character and giving the character a name.
func (CharacterCreated) Type ¶
func (p CharacterCreated) Type() string
type CharacterStatsChanged ¶
type CharacterStatsChanged struct {
UserId int
}
any stats or healthmax etc. have changed
func (CharacterStatsChanged) Type ¶
func (p CharacterStatsChanged) Type() string
type CharacterTrained ¶
type CharacterTrained struct {
UserId int
}
Health, mana, etc.
func (CharacterTrained) Type ¶
func (p CharacterTrained) Type() string
type CharacterVitalsChanged ¶
type CharacterVitalsChanged struct {
UserId int
}
Health, mana, etc.
func (CharacterVitalsChanged) Type ¶
func (p CharacterVitalsChanged) Type() string
type Communication ¶
type Communication struct { SourceUserId int // User that sent the message SourceMobInstanceId int // Mob that sent the message TargetUserId int // Sent to only 1 person CommType string // say, party, broadcast, whisper, shout Name string Message string }
func (Communication) Type ¶
func (m Communication) Type() string
type DayNightCycle ¶
func (DayNightCycle) Type ¶
func (l DayNightCycle) Type() string
type EquipmentChange ¶
type EquipmentChange struct { UserId int MobInstanceId int GoldChange int BankChange int ItemsWorn []items.Item ItemsRemoved []items.Item }
Gained or lost an item
func (EquipmentChange) Type ¶
func (i EquipmentChange) Type() string
type EventFlag ¶
type EventFlag uint64
const ( // Not using iota here to avoid accidentally renumbering if they get moved around. CmdNone EventFlag = 0 CmdSkipScripts EventFlag = 0b00000001 // Skip any scripts that would normally process this command CmdSecretly EventFlag = 0b00000010 // User beahvior should not be alerted to the room CmdIsRequeue EventFlag = 0b00000100 // This command was a requeue. The flag is intended to help avoid a infinite requeue loop. CmdBlockInput EventFlag = 0b00001000 // This command when started sets user input to blocking all commands that don't AllowWhenDowned. CmdUnBlockInput EventFlag = 0b00010000 // When this command finishes, it will make sure user input is not blocked. CmdBlockInputUntilComplete EventFlag = CmdBlockInput | CmdUnBlockInput // SHortcut to include both in one command )
type GainExperience ¶
func (GainExperience) Type ¶
func (l GainExperience) Type() string
type GenericEvent ¶
Generic events are mostly used for plugins
type Input ¶
type Input struct { UserId int MobInstanceId int InputText string ReadyTurn uint64 Flags EventFlag }
Used for Input from players/mobs
type ItemOwnership ¶
Gained or lost an item
func (ItemOwnership) Type ¶
func (i ItemOwnership) Type() string
type LevelUp ¶
type Listener ¶
type Listener func(Event) ListenerReturn
Return false to stop further handling of this event.
type ListenerId ¶
type ListenerId uint64
func RegisterListener ¶
func RegisterListener(emptyEvent any, cbFunc Listener, qFlag ...QueueFlag) ListenerId
Returns an ID for the listener which can be used to unregister later.
type ListenerReturn ¶
type ListenerReturn int8
func DoListeners ¶
func DoListeners(e Event) ListenerReturn
type ListenerWrapper ¶
type ListenerWrapper struct {
// contains filtered or unexported fields
}
type Log ¶
type Log struct { FollowAdd connections.ConnectionId FollowRemove connections.ConnectionId Level string Data []any }
type MSP ¶
type MSP struct { UserId int SoundType string // SOUND or MUSIC SoundFile string Volume int // 1-100 Category string // special category/type for MSP string }
Payloads describing sound/music to play
type Message ¶
type MobDeath ¶
type Party ¶
type PartyUpdated ¶
any stats or healthmax etc. have changed
func (PartyUpdated) Type ¶
func (p PartyUpdated) Type() string
type PlayerDeath ¶
type PlayerDeath struct { UserId int RoomId int Username string CharacterName string Permanent bool KilledByUsers []int }
func (PlayerDeath) Type ¶
func (l PlayerDeath) Type() string
type PlayerDespawn ¶
type PlayerDespawn struct { UserId int RoomId int Username string CharacterName string TimeOnline string }
Left the world
func (PlayerDespawn) Type ¶
func (p PlayerDespawn) Type() string
type PlayerDrop ¶
func (PlayerDrop) Type ¶
func (l PlayerDrop) Type() string
type PlayerSpawn ¶
type PlayerSpawn struct { UserId int ConnectionId uint64 RoomId int Username string CharacterName string }
Entered the world
func (PlayerSpawn) Type ¶
func (p PlayerSpawn) Type() string
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
A go-routine safe FIFO (first in first out) data stucture.
func (*Queue[T]) Len ¶
Returns the number of elements in the queue (i.e. size/length) go-routine safe.
func (*Queue[T]) Peek ¶
func (q *Queue[T]) Peek() T
Returns a read value at the front of the queue. i.e. the oldest value in the queue. Note: this function does NOT mutate the queue. go-routine safe.
func (*Queue[T]) Poll ¶
func (q *Queue[T]) Poll() T
Returns the value at the front of the queue. i.e. the oldest value in the queue. Note: this function does mutate the queue. go-routine safe.
type RebuildMap ¶
Rebuilds mapper for a given RoomId NOTE: RoomId should USUALLY be the Room's Zone.RootRoomId
func (RebuildMap) Type ¶
func (r RebuildMap) Type() string
func (RebuildMap) UniqueID ¶
func (r RebuildMap) UniqueID() string
type RedrawPrompt ¶
func (RedrawPrompt) Type ¶
func (l RedrawPrompt) Type() string
func (RedrawPrompt) UniqueID ¶
func (l RedrawPrompt) UniqueID() string
type RoomAction ¶
type RoomAction struct { RoomId int SourceUserId int SourceMobId int Action string Details any ReadyTurn uint64 }
For special room-targetting actions
func (RoomAction) Type ¶
func (r RoomAction) Type() string
type RoomChange ¶
Fired whenever a mob or player changes rooms
func (RoomChange) Type ¶
func (r RoomChange) Type() string
type ScriptedEvent ¶
Triggered by a script
func (ScriptedEvent) Type ¶
func (s ScriptedEvent) Type() string
type UserSettingChanged ¶
func (UserSettingChanged) Type ¶
func (i UserSettingChanged) Type() string
type WebClientCommand ¶
Special commands that only the webclient is equipped to handle
func (WebClientCommand) Type ¶
func (w WebClientCommand) Type() string