xt

package
v0.0.0-...-b918371 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: ISC Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DP_TS = 1 << iota
	DP_M6
	DP_M8
	DP_M1
	DP_M2
	DP_TL
)

Variables

This section is empty.

Functions

func ShipShieldStr

func ShipShieldStr(s *Ship) int

Shield strength in MJ

func ShipSpeedMax

func ShipSpeedMax(s *Ship) int

Types

type Asteroid

type Asteroid struct {
	Type   int `x3t:"o:atype"` // 0 - ore, 1 - silicon, 2 - nividium, 3 - ice
	Amount int `x3t:"o:aamount"`
	S      int `x3t:"o:s"`

	F int `x3t:"o:f"`
	// contains filtered or unexported fields
}

type Background

type Background struct {
	S     int `x3t:"o:s"`
	Neb   int `x3t:"o:neb"`
	Stars int `x3t:"o:stars"`
}

type Cockpit

type Cockpit struct {
	BodyFile               string
	PictureID              string
	RotX                   float64
	RotY                   float64
	RotZ                   float64
	GalaxySubtype          string
	Description            string
	SceneFile              string
	LaserMask              int
	Volume                 string
	ProductionRelValNPC    string
	PriceModifier1         string
	PriceModifier2         string
	WareClass              int
	ProductionRelValPlayer string
	MinNotoriety           string
	VideoID                string
	Skin                   string
	ObjectID               string
}

type CustomisableContainer

type CustomisableContainer struct {
	S         int       `x3t:"o:s"`
	Docks     []Dock    `x3t:"ot:5"` //huh?
	Factories []Factory `x3t:"ot:6"` //huh?
	Ships     []UShip   `x3t:"ot:7"`
	Lasers    []Ware    `x3t:"ot:8"`
	Shields   []Ware    `x3t:"ot:9"`
	Missiles  []Ware    `x3t:"ot:10"`
	Energy    []Ware    `x3t:"ot:11"`
	Novelty   []Ware    `x3t:"ot:12"`
	Bio       []Ware    `x3t:"ot:13"`
	Food      []Ware    `x3t:"ot:14"`
	Mineral   []Ware    `x3t:"ot:15"`
	Tech      []Ware    `x3t:"ot:16"`
}

type Debris

type Debris struct {
	S int `x3t:"o:s"`

	Type   int `x3t:"o:atype"` // 0 - ore, 1 - silicon, 2 - nividium, 3 - ice
	Amount int `x3t:"o:aamount"`
	F      int `x3t:"o:f"`
	// contains filtered or unexported fields
}

type Dock

type Dock struct {
	S string `x3t:"o:s"`

	N int `x3t:"o:n"`
	// contains filtered or unexported fields
}

type DummyAnimated

type DummyAnimated struct {
	Id       string
	Flags    string
	Unknown1 int
	Unknown2 string
	Unknown3 int
}

type Factory

type Factory struct {
	S         string    `x3t:"o:s"`
	Docks     []Dock    `x3t:"ot:5"` // Huh?
	Factories []Factory `x3t:"ot:6"` // Huh?
	Ships     []UShip   `x3t:"ot:7"`

	N string `x3t:"o:n"`
	// contains filtered or unexported fields
}

type Gate

type Gate struct {
	Gid int `x3t:"o:gid"` // 0,1,2,3 - N,S,W,E

	// 0, 1, 2, 3 - normal gate N, S, W, E
	// 4 - destroyed
	// 5, 6, 7, 8 - Trans-orbital accelerator N, S, W, E
	// 9 - 20 - xenon hub gates
	S string `x3t:"o:s"`
	// Gx, Gy - destination sector coordinates
	Gx   int `x3t:"o:gx"`
	Gy   int `x3t:"o:gy"`
	Gtid int `x3t:"o:gtid"` // Destination gate direction.
	F    int `x3t:"o:f"`
	// contains filtered or unexported fields
}

type PageXML

type PageXML struct {
	Id    int    `xml:"id,attr"`
	Title string `xml:"title,attr"`
	Descr string `xml:"descr,attr"`
	T     []struct {
		Id    int    `xml:"id,attr"`
		Value string `xml:",chardata"`
	} `xml:"t"`
}

type Planet

type Planet struct {
	F int `x3t:"o:f"`
	S int `x3t:"o:s"`

	Color int `x3t:"o:color"`
	Fn    int `x3t:"o:fn"`
	// contains filtered or unexported fields
}

type Scene

type Scene struct {
	P []SceneP
}

type SceneP

type SceneP struct {
	P  string
	B  string
	C  string
	N  string
	BB bool
}

type Script

type Script struct {
	SourceText struct {
		Lines []struct {
			LineNr string   `xml:"linenr,attr"`
			Indent string   `xml:"indent,attr"`
			Str    []string `xml:",any"`
		} `xml:"line"`
	} `xml:"sourcetext"`
}

func DecodeScript

func DecodeScript(r io.Reader) (error, *Script)

type Sector

type Sector struct {
	F      int `x3t:"o:f"`
	X      int `x3t:"o:x"`    // map coordinates
	Y      int `x3t:"o:y"`    // map coordinates
	R      int `x3t:"o:r"`    // Race
	Size   int `x3t:"o:size"` // Radius
	M      int `x3t:"o:m"`
	P      int `x3t:"o:p"`
	Qtrade int `x3t:"o:qtrade"`
	Qfight int `x3t:"o:qfight"`
	Qthink int `x3t:"o:qthink"`
	Qbuild int `x3t:"o:qbuild"`

	Suns       []Sun      `x3t:"ot:3"`
	Asteroids  []Asteroid `x3t:"ot:17"`
	Background Background `x3t:"ot:2"`
	Planets    []Planet   `x3t:"ot:4"`
	Docks      []Dock     `x3t:"ot:5"`
	Factories  []Factory  `x3t:"ot:6"`
	Ships      []UShip    `x3t:"ot:7"`
	Missiles   []Ware     `x3t:"ot:10"`
	Food       []Ware     `x3t:"ot:14"`
	Tech       []Ware     `x3t:"ot:16"`
	Gates      []Gate     `x3t:"ot:18"`
	Specials   []Special  `x3t:"ot:20"`
	Debris     []Debris   `x3t:"ot:28"`
}

type Ship

type Ship struct {
	BodyFile  string
	PictureID string
	Yaw       float64
	Pitch     float64
	Roll      float64
	// Class - ship class. Names of classes can be changed but classes itself are hardcoded into OBJ files
	Class        string
	Description  string `x3t:"page:17"`
	Speed        int    // Seems to be scaled by 500.
	Acceleration int
	// Engine sound - Index to Sounds.txt
	EngineSound          string
	AverageReactionDelay string
	// Engine effect - Index to Effects.txt
	EngineEffect     string
	EngineGlowEffect string
	ReactorOutput    string
	SoundVolumeMax   string
	SoundVolumeMin   string
	// Ship scene - scene containing the ship graphics
	ShipScene string
	// Cockpit scene - scene containing the cockpit graphics (the real cockpit where you control the ship from)
	CockPitScene string
	//Possible lasers - bit mask
	PossibleLasers int
	// Gun count - sum of count of laser parts of all gun records
	GunCount int
	// Weapons energy - how is it related to TLaser.txt energy?
	WeaponsEnergy int
	// Weapons recharge rate - how is it related to TLaser.txt recharge rate?
	WeaponsRechargeRate float64
	// Shield type - biggest shield the ship can equip - index to TShields.txt
	//ShieldType string
	ShieldType *TShield `x3t:"tref:Shields,index"`
	// Max shield count - Maximum number of shields
	MaxShieldCount int
	// Possible missiles - bit mask
	PossibleMissiles int
	// Number of missiles (NPC) - Maximum number of missiles an NPC ship can carry
	NumberOfMissiles int
	MaxEngineTuning  int // One engine tuning seems to increase the speed by 10% of the minimum speed.
	MaxRudderTuning  int
	// Cargo min (buy) - minimum cargo capacity (when the ship is bought)
	CargoMin int
	// Cargo max - maximum cargo capacity
	CargoMax        int
	PredefinedWares string
	// Turret descriptor - fixed length array - the reason why there is only 6 + 1 turrets
	TurretDescriptor [6]struct {
		// Cockpit index - index to TCockpits.txt
		//CIndex int
		Cockpit *Cockpit `x3t:"tref:Cockpits,index"`
		// Cockpit position - front, rear, left, right, top, bottom - not sure what it's used for
		CPos int
	}
	// Docking slots - maximum number of ships which can dock
	DockingSlots int
	// Cargo type - maximum cargo size the ship can carry - Ware class of TWare.txts
	CargoType int
	// Race - Race of the ship.
	Race         int
	HullStrength int
	// Explosion definition - index to Effects.txt
	ExplosionDefinition string
	// Body explosion definition - index to Effects.txt
	BodyExplosionDefinition string
	// Engine Trail - Particle Emitter - index to Effects.txt
	EngineTrailParticleEmitter string
	// Variation index - Hauler, Vanguard,... - index to Page 17 in text resource files. The String ID is calculated as 10000 + Variation index
	Variation string `x3t:"page:17,offset:10000,ignore:20"`
	// Max Rotation Acceleration - How fast the ship can go from 0 to maximum rotation speed
	MaxRotationAcceleration int
	// Class Description - String ID from Page 17 of text resource files (no, it isn't)
	ClassDescription string
	Cockpit          []struct {
		Index       int
		TurretIndex string
		BodyID      string
		PathIndex   string
	}
	GunGroup []struct {
		// Initial laser index - calculated as 1 + count of laser parts in previous gun groups
		InitialLaserIndex int
		// No of guns - number of laser parts
		NumGuns int
		// Index - an index of the gun group - starting from 1
		GunGroupIndex int
		Gun           []struct {
			// Index - an index of the gun. The index continues between gun groups (i.e. it's unique and global)
			Index int
			// Count of laser parts - number of laser parts in BOD/BOB file
			CountLaserParts int
			// Body ID (primary) - Body ID from ship scene
			BodyID string
			// Path index (primary) - Path index from ship scene
			PathIndex string
			// Body ID (secondary) - Body ID from weapon scene
			BodyID2 string
			// Path index (secondary) - Path index from weapon scene
			PathIndex2 string
		}
	}
	Volume string
	// Production RelVal (NPC) - Price for NPCs (it's not really a price)
	ProductionRelValNPC int
	// Price modifier (1)
	PriceModifier1 int
	// Price modifier (2)
	PriceModifier2 int
	WareClass      int
	// Production RelVal (player) - Price for the player (it's not really a price)
	ProductionRelValPlayer int
	// Min. Notoriety - minimum notoriety the player must have with corresponding race to be able to buy the ship
	MinNotoriety int
	// Video ID - ignored
	VideoID string
	// Unknown value
	UknownValue string
	ObjectID    string
}

type Special

type Special struct {
	S string `x3t:"o:s"`

	V int `x3t:"o:v"`
	F int `x3t:"o:f"`
	// contains filtered or unexported fields
}

type Sun

type Sun struct {
	S int `x3t:"o:s"`

	Color int `x3t:"o:color"`
	F     int `x3t:"o:f"`
	// contains filtered or unexported fields
}

type TBullet

type TBullet struct {
	BodyFile               string
	PictureID              string
	Yaw                    float64
	Pitch                  float64
	Roll                   float64
	Index                  string
	Description            string `x3t:"page:17"`
	ShieldDamage           int
	EnergyUsed             int
	Sound                  string // index to Sounds.txt
	Lifetime               int
	Speed                  int
	Flags                  int
	ColorB                 int
	ColorG                 int
	ColorR                 int
	SizeX                  float64
	SizeY                  float64
	SizeZ                  float64
	EngineEffect           string // Effects.txt
	ImpactEffect           string // Effects.txt
	LauchEffect            string // Effects.txt
	HullDamage             int
	EngineTrail            string
	AmbientSound           string // Sounds.txt
	VolumeMin              int
	VolumeMax              int
	Unknown1               int
	Unknown2               int
	Unknown3               int
	Unknown4               int
	Unknown5               int
	Unknown6               int
	Unknown7               int
	Unknown8               int
	Unknown9               int
	Unknown10              int
	Unknown11              int
	Unknown12              int
	Ammo                   string // TWareT.txt (or 128?)
	ProductionRelValNPC    int
	PriceModifier1         int
	PriceModifier2         int
	WareClass              int
	ProductionRelValPlayer int
	MinNotoriety           int
	VideoID                string
	Skin                   string
	ObjectID               string
}

type TDock

type TDock struct {
	BodyFile               string
	PictureID              string
	RotX                   float64
	RotY                   float64
	RotZ                   float64
	GalaxySubtype          string
	Description            string `x3t:"page:17"`
	SoundID                string
	DockDistance           string
	RendezvousDistrance    string
	ThreeDSoundVolume      string
	SceneFile              string
	InnerScene             string
	Race                   int
	Explosion              string
	BodyExplosion          string
	ShieldPowerGen         string
	HUDIcon                string
	Volume                 string
	ProductionRelValNPC    int
	PriceModifier1         int
	PriseModifier2         int
	WareClass              int
	ProductionRelValPlayer int
	MinNotoriety           int
	VideoID                string
	Skin                   string
	ObjectID               string
}

type TLaser

type TLaser struct {
	BodyFile               string
	PictureID              string
	RotX                   float64
	RotY                   float64
	RotZ                   float64
	Index                  string
	Description            string `x3t:"page:17"`
	RoF                    int    // 1 shot per RoF milliseconds
	Sound                  int
	Projectile             *TBullet `x3t:"tref:Bullets,index"`
	Energy                 int
	ChargeRate             float64
	HUDIcon                string
	Volume                 string
	ProductionRelValNPC    string
	PriceMod1              string
	PriceMod2              string
	WareClass              int
	ProductionRelValPlayer string
	MinNotoriety           string
	VideoID                string
	Skin                   string
	OjectID                string
}

type TShield

type TShield struct {
	BodyFile               string
	PictureID              string
	Yaw                    float64
	Pitch                  float64
	Roll                   float64
	Index                  string
	Description            string `x3t:"page:17"`
	ChargeRate             int    // kJ/s
	Strength               int    // kJ
	HitEffect              string
	Efficiency             string
	Volume                 string
	ProductionRelValNPC    int
	PriceModifier1         int
	PriceModifier2         int
	WareClass              int
	ProductionRelValPlayer int
	MinNotoriety           int
	VideoID                string
	Skin                   string
	ObjectID               string
}

type TSun

type TSun struct {
	Unknown01  int
	Unknown02  int
	Unknown03  int
	Unknown04  int
	Unknown05  float64
	Unknown06  int
	Unknown07  int
	Unknown08  int
	Unknown09  int
	Brightness int // Seems to be fixed point scaled by 2^16
	Unknown11  int
	Unknown12  int
	Unknown13  int
	Unknown14  int
	Unknown15  int
	Unknown16  int
	Unknown17  int
	Unknown18  int
	ObjectID   string
}

the only documentation of this I found was wrong.

type Text

type Text map[int]map[int]string

func (Text) Get

func (t Text) Get(pid, tid int) (string, error)

type TextFile

type TextFile struct {
	Language struct {
		Id int `xml:"id,attr"`
	} `xml:"language"`
	Pages []PageXML `xml:"page"`
}

type UShip

type UShip struct {
	S string `x3t:"o:s"`
	F int    `x3t:"o:f"`

	Ships []UShip                 `x3t:"ot:7"`
	CCs   []CustomisableContainer `x3t:"ot:23"`
	// contains filtered or unexported fields
}

type Universe

type Universe struct {
	Sectors   []Sector  `x3t:"ot:1"`
	Debris    []Debris  `x3t:"ot:28"`
	Specials  []Special `x3t:"ot:20"`
	Factories []Factory `x3t:"ot:6"`
	Docks     []Dock    `x3t:"ot:5"`
}

func (Universe) SectorXY

func (u Universe) SectorXY(x, y int) *Sector

type Ware

type Ware struct {
	F int    `x3t:"o:f"`
	S string `x3t:"o:s"`
	I int    `x3t:"o:i"`

	N int `x3t:"o:n"`
	// contains filtered or unexported fields
}

type X

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

Each thing we access is loaded and parsed on demand. To synchronize this, each member is protected by a sync.Once.

func NewX

func NewX(dir string) *X

Get all the information we can get from an X3 installation.

func (*X) AsteroidType

func (x *X) AsteroidType(i int) string

func (*X) DockByID

func (x *X) DockByID(id string) *TDock

func (*X) DockPorts

func (x *X) DockPorts() map[string]int

func (*X) GetDum

func (x *X) GetDum() []DummyAnimated

func (*X) GetLasers

func (x *X) GetLasers() []TLaser

func (*X) GetShields

func (x *X) GetShields() []TShield

func (*X) GetShips

func (x *X) GetShips() []Ship

func (*X) GetSuns

func (x *X) GetSuns() []TSun

func (*X) GetText

func (x *X) GetText() Text

func (*X) GetUniverse

func (x *X) GetUniverse() (u Universe)

func (*X) LtMask

func (x *X) LtMask(lt string) uint

func (*X) Map

func (x *X) Map(f func(string, string))

func (*X) Open

func (x *X) Open(f string) io.ReadCloser

func (*X) PreCache

func (x *X) PreCache()

Asynchronously pre-cache everything we might want to load later.

func (*X) RaceName

func (x *X) RaceName(r int) string

func (*X) Scene

func (x *X) Scene(f string) *Scene

func (*X) SectorFlavor

func (x *X) SectorFlavor(s *Sector) string

func (*X) SectorName

func (x *X) SectorName(s *Sector) string

func (*X) ShipDock

func (x *X) ShipDock(s *Ship) map[string]int

func (*X) ShipNonFighterDock

func (x *X) ShipNonFighterDock(s *Ship) int

func (*X) SunPercent

func (x *X) SunPercent(s *Sector) int

type Xdata

type Xdata interface {
	Open() io.ReadCloser
}

type Xfiles

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

func XFiles

func XFiles(dir string) Xfiles

func (*Xfiles) Map

func (xf *Xfiles) Map(f func(string, string))

func (*Xfiles) Open

func (xf *Xfiles) Open(fname string) io.ReadCloser

Directories

Path Synopsis
bob
gen command

Jump to

Keyboard shortcuts

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