bpdraw

package
v0.0.0-...-7d29625 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FactorioPath string
View Source
var ImgCache map[string]image.Image

Functions

func Draw

func Draw(ents []Entity, dst *image.RGBA, info map[string]EntityInfo)

Main drawing function. Calls the corresponding drawing functions for every entity in the blueprint ents - entity array from the blueprint string dst - the image used as a canvas for drawing

func Init

func Init(ents []Entity, offx, offy float64) *image.RGBA

Initializes drawing canvas with the right size ents - entity array from blueprint string offx - by how much change the X axis so that the smallest X coordinate in blueprint is on 0 offx - Y Y returns the image canvas pointer and all drawers that are needed for this blueprint render

func LoadImage

func LoadImage(name, fname string) (image.Image, error)

Reads entity texture If the entity is animated, the entire texture atlas is returned

func ParseEntityInfo

func ParseEntityInfo() map[string]EntityInfo

Types

type Blueprint

type Blueprint struct {
	Item       string           `json:"item"`
	Label      string           `json:"label"`
	LabelColor color.RGBA       `json:"label_color"`
	Entities   []Entity         `json:"entities"`
	Tiles      []Tile           `json:"tiles"`
	Icons      []Icon           `json:"icons"`
	Schedules  []ScheduleObject `json:"schedules"`
	Version    int64            `json:"version"`
}

func ParseBPString

func ParseBPString(s string) (Blueprint, error)

func (*Blueprint) FindZero

func (b *Blueprint) FindZero() (float64, float64)

finds the offsets for each axis so that those axis are always positive and start at 0 0 because factorio blueprint coordinates are taken from the game 1:1

type BpParse

type BpParse struct {
	BP Blueprint `json:"blueprint"`
}

type Connection

type Connection struct {
	One ConnectionPoint `json:"1"`
	Two ConnectionPoint `json:"2"`
}

type ConnectionDataObject

type ConnectionDataObject struct {
	EntityId  int `json:"entity_id"`
	CircuitId int `json:"circuit_id"`
}

type ConnectionPoint

type ConnectionPoint struct {
	Red   []ConnectionDataObject `json:"red"`
	Green []ConnectionDataObject `json:"green"`
}

type Entity

type Entity struct {
	Number      int            `json:"entity_number"`
	Name        string         `json:"name"`
	Position    PositionObject `json:"position"`
	Direction   int            `json:"direction"`
	Orientation float64        `json:"orientation"`
	Connections Connection     `json:"connections"`
	//TODO: controlBehaviour
	Items              ItemRequestObject           `json:"items"`
	Recipe             string                      `json:"recipe"`
	Bar                int                         `json:"bar"`
	Inventory          InventoryObject             `json:"inventory"`
	Type               string                      `json:"type"`
	InputPriority      string                      `json:"input_priority"`
	OutputPriority     string                      `json:"output_priority"`
	Filter             string                      `json:"filter"`
	Filters            []ItemFilterObject          `json:"filters"`
	FilterMode         string                      `json:"filter_mode"`
	OverrideStackSize  uint8                       `json:"override_stack_size"`
	DropPosition       PositionObject              `json:"drop_position"`
	PickupPosition     PositionObject              `json:"pickup_position"`
	RequestFilters     []LogisticsFilterObject     `json:"request_filters"`
	RequestFromBuffers bool                        `json:"request_from_buffers"`
	Parameters         SpeakerParameterObject      `json:"parameters"`
	AlertParameters    SpeakerAlertParameterObject `json:"alert_parameters"`
	AutoLaunch         bool                        `json:"auto_launch"`
	Color              color.RGBA                  `json:"color"`
	Station            string                      `json:"station"`
}

type EntityInfo

type EntityInfo struct {
	Picture Picture `json:"picture"`
}

type HrLayer

type HrLayer struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

type Icon

type Icon struct {
	Index  int      `json:"index"`
	Signal SignalId `json:"signal"`
}

type InventoryObject

type InventoryObject struct {
	Filters []ItemFilterObject `json:"filters"`
	Bar     int                `json:"bar"`
}

type ItemFilterObject

type ItemFilterObject struct {
	Name  string `json:"name"`
	Index int    `json:"index"`
}

type ItemRequestObject

type ItemRequestObject struct {
	Key   string `json:"key"`
	Value int    `json:"value"`
}

type Layer

type Layer struct {
	HrVersion  HrLayer   `json:"hr_version"`
	Height     int       `json:"width"`
	Shift      []float64 `json:"shift"`
	Path       string    `json:"filename"`
	LineLenght int       `json:"line_lenght"`
	FrameCount int       `json:"frame_count"`
}

type LogisticsFilterObject

type LogisticsFilterObject struct {
	Name  string `json:"name"`
	Index int    `json:"index"`
	Count int    `json:"count"`
}

type Orientation

type Orientation struct {
	Layers []Layer `json:"layers"`
}

type Picture

type Picture struct {
	Layers []Layer     `json:"layers"`
	North  Orientation `json:"north"`
	West   Orientation `json:"west"`
	East   Orientation `json:"east"`
	South  Orientation `json:"south"`
}

type PositionObject

type PositionObject struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type ScheduleObject

type ScheduleObject struct {
	Schedule    []ScheduleRecord `json:"entity_number"`
	Locomotives int              `json:"entity_number"`
}

type ScheduleRecord

type ScheduleRecord struct {
	Station        string          `json:"entity_number"`
	WaitConditions []WaitCondition `json:"entity_number"`
}

type SignalId

type SignalId struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type SpeakerAlertParameterObject

type SpeakerAlertParameterObject struct {
	ShowAlert    bool     `json:"show_alert"`
	ShowOnMap    bool     `json:"show_on_map"`
	IconSignalId SignalId `json:"icon_signal_id"`
	AlertMessage string   `json:"alert_message"`
}

type SpeakerParameterObject

type SpeakerParameterObject struct {
	PlaybackVolume   float64 `json:"playback_volume"`
	PlaybackGlobally bool    `json:"playback_globally"`
	AllowPolyphony   bool    `json:"allow_polyphony"`
}

type Tile

type Tile struct {
	Name     string         `json:"name"`
	Position PositionObject `json:"position"`
}

type WaitCondition

type WaitCondition struct {
	Type        string `json:"type"`
	CompareType string `json:"compare_type"`
	Ticks       uint   `json:"ticks"`
}

Jump to

Keyboard shortcuts

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