common

package
v0.0.0-...-3f89074 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MainClientRole     = "main"
	SearcherClientRole = "searcher"
	PassiveClientRole  = "passive"
	InactiveClientRole = "inactive"
)

Variables

View Source
var (
	RestartSignal   = errors.New("restart")   // Restarts the routine
	TerminateSignal = errors.New("terminate") // Terminates the routine
	RetrySignal     = errors.New("retry")     // Retry the current action
	StepBackSignal  = errors.New("step back") // Step back to the last action

)
View Source
var Routines = make(map[RoutineKind]Actions)
View Source
var Send = struct{}{}

Functions

func Console

func Console(level logging.LogLevel, text string)

Types

type Action

type Action interface {
	Execute(macro *Macro) error
}

type ActionResults

type ActionResults struct {
	EditedScreenshot  *image.RGBA
	ImageSearchPoints []revimg.Point
}

type Actions

type Actions []Action

func (Actions) Register

func (a Actions) Register(kind RoutineKind)

type Alignment

type Alignment interface {
	PerformDetection(macro *Macro)
}

type Backend

type Backend interface {
	KeyDown(pid int, key Key)
	KeyUp(pid int, key Key)
	MoveMouse(x, y int)
	ScrollMouse(x, y int)
	Sleep(ms int, interrupt Receiver)
	SleepAsync(ms int, interrupt Receiver) Receiver
	AttachInput(pid int)
}

type BuffDetector

type BuffDetector interface {
	Tick(origin *revimg.Point, screenshot *image.RGBA)
	MoveSpeed() float64
	Watch() chan struct{}
	Unwatch(chan struct{})
}

type ClientRole

type ClientRole string

type Event

type Event interface {
	Execute(backend Backend)
}

type EventBus

type EventBus interface {
	Start()
	KeyDown(window *Macro, key Key) Receiver
	KeyUp(macro *Macro, key Key) Receiver
	MoveMouse(macro *Macro, x, y int) Receiver
	ScrollMouse(macro *Macro, x, y int) Receiver
}

type InputManager

type InputManager interface {
	Reset()
	ResetCharacter()
	KeyDown(key Key)
	KeyUp(key Key)
	KeyPress(key Key)
	SetPitch(pitch int)
	SetYaw(yaw int)
	SetZoom(zoom int)
	Pitch() int
	Yaw() int
	Zoom() int
	Sleep(ms int)
}

type InterruptKind

type InterruptKind int
const (
	DelayedInterrupt InterruptKind = iota
	IntervalInterrupt
)

type Key

type Key int
const (
	Forward Key = iota
	Backward
	Left
	Right
	RotLeft
	RotRight
	RotUp
	RotDown
	ZoomIn
	ZoomOut
	E
	R
	L
	Esc
	Enter
	LShift
	Space
	One
	Two
	Three
	Four
	Five
	Six
	Seven
)

type Macro

type Macro struct {
	sync.Mutex

	Root *Macro

	CancelPattern context.CancelFunc

	Account    string
	EventBus   EventBus
	Input      InputManager
	Backend    Backend
	Scheduler  Scheduler
	Results    *ActionResults
	State      *config.Object[config.State]
	MacroState *config.Object[config.MacroState]
	Settings   *config.Object[config.Settings]
	Database   *config.Object[config.AccountDatabase]
	Network    *Network
	VicHop     VicHop
	BuffDetect BuffDetector
	Pattern    PatternLoader
	Logger     *logging.Logger
	Window     *window.Window
	WinManager *window.Manager
	Scratch    *config.Scratch

	Routine    RoutineExecutor
	Subroutine SubroutineExecutor
	Action     func(Action) error
	Status     func(string)
	Pause      <-chan (<-chan struct{})
	Stop       chan struct{}
	Error      chan string
	Redirect   chan *RedirectExecution

	Watchers        []chan (<-chan struct{})
	UnpauseWatchers []chan<- struct{}
}

func (*Macro) Copy

func (m *Macro) Copy() *Macro

func (*Macro) GetRoot

func (m *Macro) GetRoot() *Macro

func (*Macro) GetWindow

func (m *Macro) GetWindow() *window.Window

func (*Macro) SetError

func (m *Macro) SetError(err error, context string)

func (*Macro) SetRedirect

func (m *Macro) SetRedirect(routine RoutineKind) error

func (*Macro) Unwatch

func (m *Macro) Unwatch(ch <-chan (<-chan struct{}))

func (*Macro) Watch

func (m *Macro) Watch() <-chan (<-chan struct{})

Watch returns channel which outputs a channel or a nil value whenever the macro is paused or stopped. If a new channel is received, it indicates that the macro is paused and that the channel should be used to wait for unpause. This function must be used in asynchronous operations that are executed outside the routine loop.

type Message

type Message struct {
	Kind     MessageKind
	Sender   string
	Receiver string
	Content  string

	Data []byte `json:"-"`
}

type MessageKind

type MessageKind int
const (
	RegistrationMessageKind MessageKind = iota
	AckRegistrationMessageKind
	ConnectedIdentitiesMessageKind
	SetRoleMessageKind
	AckSetRoleMessageKind
	VicDetectMessageKind
	NightDetectMessageKind
	SearchedServerMessageKind
	ShutdownMessageKind
	UnknownMessageKind
)

type Network

type Network struct {
	Client   NetworkClient
	Relay    NetworkRelay
	Watchers []chan *Message
}

type NetworkClient

type NetworkClient interface {
	Start()
	Close()
	Subscribe(kind MessageKind) chan *Message
	SubscribeOnce(kind MessageKind) <-chan *Message
	SetRole(ClientRole) error
	Send(receiver string, content interface{})
	Broadcast(content interface{})
	Connect(address string) error
	Disconnect()
	UnsubscribeAll()
}

type NetworkRelay

type NetworkRelay interface {
}

type PatternLoader

type PatternLoader interface {
	Start() error
	Patterns() []string
	Exists(pattern string) bool
	Execute(macro *Macro, meta *config.PatternMetadata, pattern string) error
}

type Receiver

type Receiver <-chan struct{}

type RedirectExecution

type RedirectExecution struct {
	Routine RoutineKind
}

func (RedirectExecution) Error

func (e RedirectExecution) Error() string

type RoutineExecutor

type RoutineExecutor func(kind RoutineKind)

type RoutineKind

type RoutineKind string

type Scheduler

type Scheduler interface {
	Execute(interruptType InterruptKind)
	Start()
	Close()
	Initialize(macro *Macro)
	RequestFrame() <-chan *image.RGBA
}

type SubroutineExecutor

type SubroutineExecutor func(actions []Action)

type VicHop

type VicHop interface {
	Tick(macro *Macro)
	ReadQueue(macro *Macro)
	BattleDetect(macro *Macro)
	StopBattleDetect(macro *Macro)
	BattleActive(macro *Macro) bool
	Detect(macro *Macro, field string) (bool, error)
	FindServer(macro *Macro) (string, error)
}

Jump to

Keyboard shortcuts

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