resource

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package resource provides a typed Go client for the resource and pollution commands registered by softmod/factop/resource.lua.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Area

type Area struct {
	X1 float64
	Y1 float64
	X2 float64
	Y2 float64
}

Area defines a rectangular search region.

func (Area) String

func (a Area) String() string

type Client

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

Client provides typed methods for each resource-* and pollution-* RCON command.

func New

func New(conn *client.Conn) *Client

New creates a resources Client using the given connection.

func (*Client) Count

func (c *Client) Count(surface string) ([]ResourceCount, error)

Count returns total resource counts for the surface.

func (*Client) Find

func (c *Client) Find(area Area, name string, limit int, surface string) ([]Resource, error)

Find returns resource entities in the given area.

func (*Client) GetPollution

func (c *Client) GetPollution(x, y float64, surface string) (float64, error)

GetPollution returns the pollution value at the given position.

func (*Client) SetAmount

func (c *Client) SetAmount(x, y float64, amount uint32, surface string) (string, error)

SetAmount sets the resource amount at the given position.

func (*Client) SetPollution

func (c *Client) SetPollution(x, y, amount float64, surface string) (string, error)

SetPollution sets the pollution value at the given position.

func (*Client) TotalPollution

func (c *Client) TotalPollution(surface string) (float64, error)

TotalPollution returns the total pollution on the surface.

type Resource

type Resource struct {
	Name   string  `json:"name"`
	X      float64 `json:"x"`
	Y      float64 `json:"y"`
	Amount uint32  `json:"amount"`
}

Resource is a resource entity with position and amount.

func ParseResources

func ParseResources(s string) ([]Resource, error)

ParseResources parses the resource-find wire format: name:x:y:amount,...

type ResourceCount

type ResourceCount struct {
	Name  string `json:"name"`
	Count uint64 `json:"count"`
}

ResourceCount is a resource name and its total count on a surface.

func ParseCounts

func ParseCounts(s string) ([]ResourceCount, error)

ParseCounts parses the resource-count wire format: name:count,name:count,...

Jump to

Keyboard shortcuts

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