commons

package
v0.0.0-...-32a2d26 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SYS_MARCH = iota
	SYS_SHUNTER
	SYS_WARP
	SYS_SHIELD
	SYS_RADAR
	SYS_SCANNER
	SYS_FUEL
	SYS_LSS
)
View Source
const (
	BUILDING_BLACKBOX  = "BUILDING_BLACKBOX"
	BUILDING_MINE      = "BUILDING_MINE"
	BUILDING_BEACON    = "BUILDING_BEACON"
	BUILDING_FISHHOUSE = "BUILDING_FISHHOUSE"
)
View Source
const (
	//google-disney
	OWNER_1 = "gd"
	//pony-express
	OWNER_2 = "pre"
	//mars-stroy-trest
	OWNER_3 = "mst"
	//mitsibishi-autovaz
	OWNER_4 = "mat"
	//red-cross
	OWNER_5 = "kkg"
)
View Source
const (
	ROLE_Pilot  = "Pilot"
	ROLE_Engi   = "Engi"
	ROLE_Navi   = "Navi"
	ROLE_Server = "Server"
)
View Source
const (
	STATE_login = "login"
	STATE_cosmo = "cosmo"
	STATE_warp  = "warp"
)
View Source
const (
	START_Galaxy_ID = "solar"
	WARP_Galaxy_ID  = "warp"
	ZERO_Galaxy_ID  = "zero"
)
View Source
const (
	CMD_STATECHANGEFAIL = "FailedStateChange"
	CMD_BUILDINGEVENT   = "BuildEvent"        //from server to subscribed clients
	CMD_ADDBUILDREQ     = "AddBuildingReq"    //from client to server
	CMD_DELBUILDREQ     = "DeleteBuildingReq" //from client to server
	CMD_LOGGAMEEVENT    = "LogGameEvent"      //from client to server
	CMD_GRACEENDDIE     = "GraceEndDie"       //from client to server
	CMD_GRACEENDRETURN  = "GraceEndReturn"    //from client to server
)
View Source
const (
	//also MAGIC_MARK_BUILDING_BEACON, MAGIC_MARK_BUILDING_BLACKBOX
	//
	//also MAGIC_DEFAULT_STAR, MAGIC_DEFAULT_HARDPLANET, MAGIC_DEFAULT_GASPLANET,
	// MAGIC_DEFAULT_ASTEROID, MAGIC_DEFAULT_WARP
	//
	//also MAGIC_MARK_STAR, MAGIC_DEFAULT_HARDPLANET, MAGIC_DEFAULT_GASPLANET,
	// MAGIC_MARK_ASTEROID, MAGIC_MARK_WARP
	ShipAN              = "MAGIC_ship"
	MARKtheEarthAN      = "MAGIC_MARK_theearth"
	MARKtheMagellanAN   = "MAGIC_MARK_themagellan"
	MARKGLOWAN          = "MAGIC_MARK_GLOW"
	MARKShipAN          = "MAGIC_MARK_ship"
	OtherShipAN         = "MAGIC_othership"
	MARKOtherShipAN     = "MAGIC_MARK_othership"
	PredictorAN         = "MAGIC_predictor"
	NaviMarkerAN        = "MAGIC_navimarker"
	TrailAN             = "MAGIC_trail"
	ScannerAN           = "MAGIC_scanner"
	ThrustArrowAN       = "MAGIC_thurstarrow"
	RulerHAN            = "MAGIC_rulerh"
	RulerVAN            = "MAGIC_rulerv"
	RulerWarpHAN        = "MAGIC_warprulerh"
	RulerWarpVAN        = "MAGIC_warprulerv"
	DefaultBackgroundAN = "MAGIC_DEFAULT_background"
	EngiBackgroundAN    = "MAGIC_engibackground"
	WarpBackgroundAN    = "MAGIC_warpbackground"
	CompassAN           = "MAGIC_compass"
	Frame9AN            = "front9"
	ButtonAN            = "MAGIC_button"
	TextPanelAN         = "MAGIC_textpanel"
	WayPointAN          = "MAGIC_waypoint"
	WayArrowAN          = "MAGIC_wayarrow"
	WarpInnerAN         = "MAGIC_warpinner"
	WarpOuterAN         = "MAGIC_warpouter"
	WarpGreenAN         = "MAGIC_warpgreen"
)
View Source
const (
	EMI_DMG_MECH       = "1"  //in Engi Counters
	EMI_DMG_HEAT       = "2"  //in Engi Counters
	EMI_DMG_RADI       = "3"  //in Engi Counters
	EMI_DMG_GRAVI      = "4"  //in pilot warpscene -> engi command GDmgHard GDmgMedium
	EMI_VEL_UP         = "5"  //Pilot cosmoscene procEmi
	EMI_VEL_DOWN       = "6"  //Pilot cosmoscene procEmi
	EMI_DIST_UP        = "7"  //in Engi into BSPDegrade
	EMI_DIST_DOWN      = "8"  //in Engi into BSPDegrade
	EMI_WARP_TURN      = "9"  //in Engi into BSPDegrade
	EMI_ACCEL          = "10" //in Engi into BSPDegrade
	EMI_REVERSE        = "11" //in Engi into BSPDegrade
	EMI_ENGINE_HEAT    = "12" //in Engi into BSPDegrade
	EMI_FUEL           = "13" //in Engi into BSPDegrade
	EMI_TURN           = "14" //in Engi into BSPDegrade
	EMI_STRAFE         = "15" //in Engi into BSPDegrade
	EMI_SCAN_RADIUS    = "16" //in Engi into BSPDegrade
	EMI_SCAN_SPEED     = "17" //in Engi into BSPDegrade
	EMI_DROP_RADIUS    = "18" //in Engi into BSPDegrade
	EMI_DROP_SPEED     = "19" //in Engi into BSPDegrade
	EMI_RADAR_COSMOS   = "20" //in Engi into BSPDegrade
	EMI_RADAR_WARP     = "21" //in Engi into BSPDegrade
	EMI_RADAR_ANG_UP   = "22" //in Engi into BSPDegrade
	EMI_RADAR_ANG_DOWN = "23" //in Engi into BSPDegrade
	EMI_CO2            = "24" //in Engi into BSPDegrade
	EMI_DEF_HEAT       = "25" //in Engi into BSPDegrade
	EMI_DEF_RADI       = "26" //in Engi into BSPDegrade
	EMI_DEF_MECH       = "27" //in Engi into BSPDegrade
	EMI_WORMHOLE       = "28" //Engi update checks
)
View Source
const (
	//GalaxyPoint.Type
	//also includes outerBuilds (BUILDING_BLACKBOX, BUILDING_BEACON)
	GPT_STAR       = "STAR"
	GPT_WARP       = "WARP"
	GPT_HARDPLANET = "HARDPLANET"
	GPT_GASPLANET  = "GASPLANET"
	GPT_ASTEROID   = "ASTEROID"
	GPT_WORMHOLE   = "WORMHOLE"
)
View Source
const (
	SIG_SPAWNPERIOD = "SpawnPeriod"
	SIG_LIFETIME    = "LifeTime"
	SIG_VELSPAWN    = "VelAndSpawnStr"
	SIG_ANGF        = "AngStr"
	SIG_SIZEF       = "SizeStr"
	SIG_ALPHAF      = "AlphaStr"
)
View Source
const BuildingSize = 20

fixed

View Source
const ShipSize = 20
View Source
const WormHoleFN = "wormholes.json"
View Source
const WormHolePeriod = 60 * 15

in seconds

View Source
const WormHoleYouDIE = "DIE!"

Variables

View Source
var (
	StartDateTime = time.Date(2018, 01, 01, 01, 01, 01, 01, time.Local)
)
View Source
var VelDistWarpK float64

Functions

func Add1

func Add1(x *float64, delta float64)

add delta to X, but X can't be more than 1

func AddBeacon

func AddBeacon(Data TData, Client *network.Client, msg string)

func AddFishHouse

func AddFishHouse(Data TData, Client *network.Client, planetID string, owner string)

func AddMine

func AddMine(Data TData, Client *network.Client, planetID string, owner string)

func CalculateEmissions

func CalculateEmissions(galaxy *Galaxy, ship v2.V2) (res map[string]float64)

func Clamp

func Clamp(x, min, max float64) float64

func ClientLogGame

func ClientLogGame(Client *network.Client, key string, args ...interface{})

for clients

func ColorByOwner

func ColorByOwner(owner string) color.Color

func CompanyNameByOwner

func CompanyNameByOwner(owner string) string

func DoReq

func DoReq(Method string, addr string, body []byte) (respBody []byte, err error)

func EventToCommand

func EventToCommand(e storage.Event) string

func GetCurrentWormHoleDirectionN

func GetCurrentWormHoleDirectionN() map[string]WormHoleDirN

func GetWormHoleTarget

func GetWormHoleTarget(src string) (string, error)

func GetWormHolesNs

func GetWormHolesNs() map[int]struct{}

func Gravity

func Gravity(mass, lenSqr, zDist float64) float64

gravity acceleration (g) from planet with given mass at given range

func InitSignatureAtlas

func InitSignatureAtlas()

func InitWormHoles

func InitWormHoles()

func KDev

func KDev(devProcent float64) float64

Возвращает коэффициент нормальной дистрибуций сигма в процентах devProcent 68% попадут в (100-devProcent, 100+devProcent) 95% попадут в (100-2*devProcent, 100+2*devProcent) Отклонения больше 3 сигма ограничиваются

func RequestNewBuilding

func RequestNewBuilding(client *network.Client, b Building)

func RequestRemoveBuilding

func RequestRemoveBuilding(client *network.Client, fullKey string)

func SetGravityConsts

func SetGravityConsts(G, W float64)

func SetVelDistWarpK

func SetVelDistWarpK(k float64)

func SetWarpGravThreshold

func SetWarpGravThreshold(v float64)

func StartProfile

func StartProfile(prefix string, debugPort string)

func StopProfile

func StopProfile(prefix string)

func SumGravityAcc

func SumGravityAcc(pos v2.V2, galaxy *Galaxy) (sumF v2.V2)

func SumGravityAccWithReport

func SumGravityAccWithReport(pos v2.V2, galaxy *Galaxy, reportLevel float64) (sumF v2.V2, report []v2.V2)

func SumWarpGravityAcc

func SumWarpGravityAcc(pos v2.V2, galaxy *Galaxy) (sumF v2.V2)

func UnGravity

func UnGravity(mass, zDist, grav float64) float64

func UpdateGalaxyAndShip

func UpdateGalaxyAndShip(data TData, sumT float64, dt float64)

func UpdateWarpAndShip

func UpdateWarpAndShip(data TData, sumT float64, dt float64, powN float64)

func WarpGravity

func WarpGravity(mass, lenSqr, zDist float64) float64

Types

type BSP

type BSP struct {
	FlightID int    `json:"flight_id"`
	Dock     int    `json:"dock"`
	HyStatus string `json:"status"`

	Ship struct {
		Name      string  `json:"name"` //human name
		NodesMass float64 `json:"nodes_weight"`
	} `json:"ship"`

	BSPParams `json:"params"`

	BSPCargo `json:"cargo"`

	KnownMinerals []struct {
		ID       string `json:"id"`
		UserName string `json:"name"`
	} `json:"known_minerals"`
}

Rework CalcDegrade on change

func (*BSP) CalcDegrade

func (base *BSP) CalcDegrade(degrade BSPDegrade) (result *BSP)

type BSPCargo

type BSPCargo struct {
	Beacons struct {
		Mass  float64 `json:"weight"`
		Count int     `json:"amount"`
	} `json:"beacons"`
	Mines []struct {
		Mass  float64 `json:"weight"`
		Owner string  `json:"company"`
	} `json:"mines"`
	Modules []struct {
		Mass   float64 `json:"weight"`
		Owner  string  `json:"company"`
		Planet string  `json:"planet_id"`
	} `json:"modules"`
}

type BSPDegrade

type BSPDegrade BSPParams

Rework CalcDegrade on change

type BSPParams

type BSPParams struct {
	//0...100
	March_engine struct {
		Thrust_max   float64 `json:"thrust"`
		Thrust_acc   float64 `json:"accel"`
		Thrust_slow  float64 `json:"slowdown"`
		Reverse_max  float64 `json:"thrust_rev"`
		Reverse_acc  float64 `json:"accel_rev"`
		Reverse_slow float64 `json:"slowdown_rev"`
		Heat_prod    float64 `json:"heat_prod"`
		AZ           float64 `json:"az_level"`
		Volume       float64 `json:"volume"`
	} `json:"march_engine"`

	Warp_engine struct {
		Distort_max            float64 `json:"distort"`
		Distort_acc            float64 `json:"distort_acc"`
		Distort_slow           float64 `json:"distort_slow"`
		Consumption            float64 `json:"consumption"`
		Warp_enter_consumption float64 `json:"warp_enter_consumption"`
		Turn_speed             float64 `json:"turn_speed"`
		Turn_consumption       float64 `json:"turn_consumption"`
		AZ                     float64 `json:"az_level"`
		Volume                 float64 `json:"volume"`
	} `json:"warp_engine"`

	Shunter struct {
		Turn_max    float64 `json:"turn"`
		Turn_acc    float64 `json:"turn_acc"`
		Turn_slow   float64 `json:"turn_slow"`
		Strafe_max  float64 `json:"strafe"`
		Strafe_acc  float64 `json:"strafe_acc"`
		Strafe_slow float64 `json:"strafe_slow"`
		Heat_prod   float64 `json:"heat_prod"`
		AZ          float64 `json:"az_level"`
		Volume      float64 `json:"volume"`
	} `json:"shunter"`

	Radar struct {
		Range_Max    float64 `json:"range_max"`
		Angle_Min    float64 `json:"angle_min"`
		Angle_Max    float64 `json:"angle_max"`
		Angle_Change float64 `json:"angle_change"`
		Range_Change float64 `json:"range_change"`
		Rotate_Speed float64 `json:"rotate_speed"`
		AZ           float64 `json:"az_level"`
		Volume       float64 `json:"volume"`
	} `json:"radar"`

	Scanner struct {
		DropRange float64 `json:"drop_range"`
		DropSpeed float64 `json:"drop_speed"`
		ScanRange float64 `json:"scan_range"`
		ScanSpeed float64 `json:"scan_speed"`
		AZ        float64 `json:"az_level"`
		Volume    float64 `json:"volume"`
	} `json:"scaner"`

	Fuel_tank struct {
		Fuel_volume     float64 `json:"fuel_volume"`
		Fuel_Protection float64 `json:"fuel_protection"`
		Radiation_def   float64 `json:"radiation_def"`
		AZ              float64 `json:"az_level"`
		Volume          float64 `json:"volume"`
	} `json:"fuel_tank"`

	Lss struct {
		Thermal_def       float64 `json:"thermal_def"`
		Co2_level         float64 `json:"co2_level"`
		Air_volume        float64 `json:"air_volume"`
		Air_prepare_speed float64 `json:"air_speed"`
		Lightness         float64 `json:"lightness"`
		AZ                float64 `json:"az_level"`
		Volume            float64 `json:"volume"`
	} `json:"lss"`

	Shields struct {
		Radiation_def   float64 `json:"radiation_def"`
		Disinfect_level float64 `json:"disinfect_level"`
		Mechanical_def  float64 `json:"mechanical_def"`
		Heat_reflection float64 `json:"heat_reflection"`
		Heat_capacity   float64 `json:"heat_capacity"`
		Heat_sink       float64 `json:"heat_sink"`
		AZ              float64 `json:"az_level"`
		Volume          float64 `json:"volume"`
	} `json:"shields"`
}

type Boost

type Boost struct {
	SysN     int
	LeftTime float64
	Power    float64
}

type Building

type Building struct {
	FullKey string

	Type string
	//where is it
	GalaxyID string
	//for mines
	PlanetID string
	//beckon and boxes are auto placed on far reach of system
	//very slow and some random if there are many
	Period float64

	Message string
	//for mines and fishhouses
	OwnerID string
}

func DecodeEvent

func DecodeEvent(buf []byte) (t int, b Building, err error)

func (Building) Decode

func (Building) Decode(buf []byte) (b Building, err error)

func (Building) Encode

func (b Building) Encode() []byte

type CommonData

type CommonData struct {
	PilotData  *PilotData  `json:"pd"`
	NaviData   *NaviData   `json:"nd"`
	EngiData   *EngiData   `json:"ed"`
	ServerData *ServerData `json:"sd"`
}

func (CommonData) Copy

func (cd CommonData) Copy() (res CommonData)

deep copy

func (CommonData) Decode

func (CommonData) Decode(buf []byte) (cd CommonData, err error)

func (CommonData) Empty

func (CommonData) Empty() CommonData

func (CommonData) Encode

func (cd CommonData) Encode() []byte

func (CommonData) FillNotNil

func (cd CommonData) FillNotNil(dest *CommonData)

func (CommonData) Part

func (cd CommonData) Part(roleName string) CommonData

func (CommonData) WithoutRole

func (cd CommonData) WithoutRole(roleName string) CommonData

type Emission

type Emission struct {
	Type      string
	MainRange float64 `json:",omitempty"`
	MainValue float64 `json:",omitempty"`
	FarRange  float64 `json:",omitempty"`
	FarValue  float64 `json:",omitempty"`
}

type EngiCounters

type EngiCounters struct {
	Fuel       float64 `json:"f,omitempty"`
	HoleSize   float64 `json:"h,omitempty"`
	Pressure   float64 `json:"p,omitempty"`
	Air        float64 `json:"a,omitempty"`
	Calories   float64 `json:"t,omitempty"`
	CO2        float64 `json:"co2,omitempty"`
	FlightTime float64 `json:"ft,omitempty"`
	Hitted     float64 `json:"ht,omitempty"`
}

type EngiData

type EngiData struct {
	//[0.0 - 1.0]
	//0 for fully OKEY, 1 - for totally DEGRADED
	BSPDegrade BSPDegrade         `json:"deg,omitempty"`
	AZ         [8]float64         `json:"az,omitempty"`
	InV        [8]uint16          `json:"inv,omitempty"`
	Emissions  map[string]float64 `json:"emm,omitempty"`

	//Counters
	Counters EngiCounters `json:"c,omitempty"`
	Boosts   []Boost      `json:"b,omitempty"`
}

type Galaxy

type Galaxy struct {
	//for systems - range of "system borders"
	SpawnDistance float64

	Points map[string]*GalaxyPoint

	//recalculated on Decode
	Ordered []*GalaxyPoint `json:"-"`
	// contains filtered or unexported fields
}

func (*Galaxy) AddBuilding

func (galaxy *Galaxy) AddBuilding(b Building)

works with already calced and ordered Galaxy

func (*Galaxy) AddWarpBuilding

func (galaxy *Galaxy) AddWarpBuilding(b Building)

works with already calced and ordered Galaxy

func (*Galaxy) DelBuilding

func (galaxy *Galaxy) DelBuilding(b Building)

works with already calced and ordered Galaxy

func (*Galaxy) DelWarpBuilding

func (galaxy *Galaxy) DelWarpBuilding(b Building)

works with already calced and ordered Galaxy

func (*Galaxy) RecalcLvls

func (galaxy *Galaxy) RecalcLvls()

func (*Galaxy) Update

func (galaxy *Galaxy) Update(sessionTime float64)

must be used once per frame, to recalc all positions

type GalaxyPoint

type GalaxyPoint struct {
	//Id setted on load from file
	ID        string `json:"id,omitempty"`
	ParentID  string `json:"pid,omitempty"`
	IsVirtual bool   `json:"iv,omitempty"`

	//found on recalc
	//phys order level
	Level int `json:"lv,omitempty"`
	//graph order level, ignore
	GLevel int `json:"gl,omitempty"`

	Pos v2.V2

	Orbit    float64 `json:"orb,omitempty"`
	Period   float64 `json:"per,omitempty"`
	AngPhase float64 `json:"ang,omitempty"`

	Type     string  `json:"t,omitempty"`
	SpriteAN string  `json:"sp,omitempty"`
	Size     float64 `json:"s,omitempty"`

	Mass   float64 `json:"m,omitempty"`
	GDepth float64 `json:"gd,omitempty"`

	//for warp points
	WarpSpawnDistance float64 `json:"wsd,omitempty"`
	WarpYellowOutDist float64 `json:"wyo,omitempty"`
	WarpGreenOutDist  float64 `json:"wgo,omitempty"`
	WarpGreenInDist   float64 `json:"wgi,omitempty"`
	WarpRedOutDist    float64 `json:"wro,omitempty"`
	//for warp points
	InnerColor color.RGBA `json:"wic,omitempty"`
	OuterColor color.RGBA `json:"woc,omitempty"`
	GreenColor color.RGBA `json:"wgc,omitempty"`

	ScanData string `json:"sd,omitempty"`

	Minerals   []int       `json:"mi,omitempty"`
	Emissions  []Emission  `json:"emm,omitempty"`
	Signatures []Signature `json:"sig,omitempty"`
	Color      color.RGBA  `json:"clr,omitempty"`

	//updated on Decode or add|del building
	//map[ownerName][]fullkey
	Mines      map[string][]string `json:"mns,omitempty"`
	FishHouses map[string]string   `json:"fhs,omitempty"`

	//for warp points
	//map[fullKey]message
	Beacons    map[string]string `json:"bcs,omitempty"`
	BlackBoxes map[string]string `json:"bbs,omitempty"`
}

func (*GalaxyPoint) Copy

func (gp *GalaxyPoint) Copy() (res *GalaxyPoint)

func (GalaxyPoint) MarshalJSON

func (gp GalaxyPoint) MarshalJSON() ([]byte, error)

type LogGameEvent

type LogGameEvent struct {
	Key         string
	Args        string
	StateFields string
}

func (LogGameEvent) Decode

func (LogGameEvent) Decode(data []byte) (res LogGameEvent, err error)
type NaviData struct {
	//drop items
	BeaconCount int `json:"bc,omitempty"`
	//[]corpName, i.e. ["gd","gd","pre"]
	//[]planetName, i.e. ["CV8-85","RD4-42-13"]
	Mines   []string `json:"mn,omitempty"`
	Landing []string `json:"ld,omitempty"`

	//cosmo
	IsScanning    bool   `json:"is,omitempty"`
	IsDrop        bool   `json:"st,omitempty"`
	ScanObjectID  string `json:"so,omitempty"`
	IsOrbiting    bool   `json:"io,omitempty"`
	OrbitObjectID string `json:"oo,omitempty"`
	ActiveMarker  bool   `json:"ma,omitempty"`
	MarkerPos     v2.V2  `json:"mp,omitempty"`

	//warp
	SonarDir   float64 `json:"sd,omitempty"`
	SonarRange float64 `json:"sr,omitempty"`
	SonarWide  float64 `json:"sw,omitempty"`

	CanLandhome bool
}

type OtherShipData

type OtherShipData struct {
	Id   string
	Name string
	Ship RBData
}

type PilotData

type PilotData struct {
	Ship        RBData  `json:"sh,omitempty"`
	SessionTime float64 `json:"ss,omitempty"`
	FlightTime  float64 `json:"ft,omitempty"`
	//for cosmo
	ThrustVector v2.V2 `json:"tv,omitempty"`
	//for warp
	Distortion float64 `json:"wd,omitempty"`
	DistTurn   float64 `json:"dt,omitempty"`
	Dir        float64 `json:"dr,omitempty"`
	//warp position for return from zero system
	WarpPos v2.V2 `json:"wp,omitempty"`

	HeatProduction float64 `json:"hp,omitempty"`

	//do not reload same Msg, cz of ship.Pos extrapolate and SessionTime+=dt
	MsgID int `json:"id"`
}

type RBData

type RBData struct {
	Pos    v2.V2
	Ang    float64
	Vel    v2.V2
	AngVel float64
}

just Rigid Body data

func (RBData) Extrapolate

func (rb RBData) Extrapolate(dt float64) RBData

type RBFollower

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

func NewRBFollower

func NewRBFollower(elastic float64) *RBFollower

func (*RBFollower) JumpTo

func (f *RBFollower) JumpTo(rb RBData)

func (*RBFollower) MoveTo

func (f *RBFollower) MoveTo(rb RBData)

func (*RBFollower) RB

func (f *RBFollower) RB() RBData

func (*RBFollower) Update

func (f *RBFollower) Update(dt float64)

type ServerData

type ServerData struct {
	OtherShips []OtherShipData

	MsgID int
}

type SessionTime

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

func NewSessionTime

func NewSessionTime(sessionTime float64) *SessionTime

func (*SessionTime) Get

func (st *SessionTime) Get() (res float64)

func (*SessionTime) MoveTo

func (st *SessionTime) MoveTo(sessionTime float64)

func (*SessionTime) Update

func (st *SessionTime) Update(dt float64)

type Signature

type Signature struct {
	TypeName  string `json:"t"`
	SigString string `json:"s",omitempty`
	//deviation of this instance
	//supposed to be Len<=1
	Dev v2.V2 `json:"d"`
}

func (Signature) DevF

func (s Signature) DevF(name string) float64

func (Signature) DevK

func (s Signature) DevK(name string, widePercent float64) float64

func (Signature) DevV

func (s Signature) DevV(name string) v2.V2

func (Signature) Particle

func (s Signature) Particle() SignatureParticle

func (Signature) Type

func (s Signature) Type() SignatureType

type SignatureAtlas

type SignatureAtlas map[string]SignatureType

type SignatureParticle

type SignatureParticle struct {
	SpriteName   string
	DoRandomLine bool
	FPS          float64
	CycleType    int
}

type SignatureParticleAtlas

type SignatureParticleAtlas map[string]SignatureParticle

type SignatureType

type SignatureType struct {
	ParticleName   string
	Color          color.RGBA
	SpawnPeriod    float64
	LifeTime       float64
	VelAndSpawnStr string
	AngStr         string
	SizeStr        string
	AlphaStr       string
	ApplyDevOn     []string
	// contains filtered or unexported fields
}

func (SignatureType) Particle

func (st SignatureType) Particle() SignatureParticle

type State

type State struct {
	StateID  string `json:"st"`
	ShipID   string `json:"sh"`
	GalaxyID string `json:"gx"`
}

func (State) Decode

func (State) Decode(data string) State

func (State) Encode

func (s State) Encode() string

type StateData

type StateData struct {
	//ServerTime time.Time
	BSP    *BSP
	Galaxy *Galaxy
	//map[fullKey]Building
	Buildings map[string]Building
}

func (StateData) Copy

func (sd StateData) Copy() (res StateData)

func (StateData) Decode

func (StateData) Decode(buf []byte) (sd StateData, err error)

func (StateData) Encode

func (sd StateData) Encode() []byte

type TData

type TData struct {
	//Main game loop will handle this
	//Mu sync.RWMutex
	State
	StateData
	CommonData

	//StateBSP * Common.Engi.BSPDegrade
	SP *BSP
	// contains filtered or unexported fields
}

func NewData

func NewData() TData

func (*TData) CalcCurMass

func (d *TData) CalcCurMass() float64

func (*TData) Decode

func (d *TData) Decode()

func (*TData) Encode

func (d *TData) Encode()

func (*TData) GetState

func (d *TData) GetState() State

func (*TData) GetStateData

func (d *TData) GetStateData() StateData

Network cycle, get data for scene.Init

func (*TData) LoadCommonData

func (d *TData) LoadCommonData(src CommonData)

Network cycle

func (*TData) MyPartToSend

func (d *TData) MyPartToSend() []byte

Network cycle

func (*TData) SetState

func (d *TData) SetState(state State)

Network cycle

func (*TData) SetStateData

func (d *TData) SetStateData(stateData StateData)

Network cycle

func (*TData) Update

func (d *TData) Update(roleName string)

Main cycle

func (*TData) WaitDone

func (d *TData) WaitDone()

Network cycle

type WormHole

type WormHole struct {
	ID       int
	System   string
	TimePlan []int
}

type WormHoleDirN

type WormHoleDirN struct {
	Src, Dest int
}

type WormHoleDirSys

type WormHoleDirSys struct {
	Src, Dest string
}

func GetCurrentWormHoleDirectionSys

func GetCurrentWormHoleDirectionSys() []WormHoleDirSys

Jump to

Keyboard shortcuts

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