Documentation
¶
Index ¶
- Constants
- Variables
- func Add1(x *float64, delta float64)
- func AddBeacon(Data TData, Client *network.Client, msg string)
- func AddFishHouse(Data TData, Client *network.Client, planetID string, owner string)
- func AddMine(Data TData, Client *network.Client, planetID string, owner string)
- func CalculateEmissions(galaxy *Galaxy, ship v2.V2) (res map[string]float64)
- func Clamp(x, min, max float64) float64
- func ClientLogGame(Client *network.Client, key string, args ...interface{})
- func ColorByOwner(owner string) color.Color
- func CompanyNameByOwner(owner string) string
- func DoReq(Method string, addr string, body []byte) (respBody []byte, err error)
- func EventToCommand(e storage.Event) string
- func GetCurrentWormHoleDirectionN() map[string]WormHoleDirN
- func GetWormHoleTarget(src string) (string, error)
- func GetWormHolesNs() map[int]struct{}
- func Gravity(mass, lenSqr, zDist float64) float64
- func InitSignatureAtlas()
- func InitWormHoles()
- func KDev(devProcent float64) float64
- func RequestNewBuilding(client *network.Client, b Building)
- func RequestRemoveBuilding(client *network.Client, fullKey string)
- func SetGravityConsts(G, W float64)
- func SetVelDistWarpK(k float64)
- func SetWarpGravThreshold(v float64)
- func StartProfile(prefix string, debugPort string)
- func StopProfile(prefix string)
- func SumGravityAcc(pos v2.V2, galaxy *Galaxy) (sumF v2.V2)
- func SumGravityAccWithReport(pos v2.V2, galaxy *Galaxy, reportLevel float64) (sumF v2.V2, report []v2.V2)
- func SumWarpGravityAcc(pos v2.V2, galaxy *Galaxy) (sumF v2.V2)
- func UnGravity(mass, zDist, grav float64) float64
- func UpdateGalaxyAndShip(data TData, sumT float64, dt float64)
- func UpdateWarpAndShip(data TData, sumT float64, dt float64, powN float64)
- func WarpGravity(mass, lenSqr, zDist float64) float64
- type BSP
- type BSPCargo
- type BSPDegrade
- type BSPParams
- type Boost
- type Building
- type CommonData
- func (cd CommonData) Copy() (res CommonData)
- func (CommonData) Decode(buf []byte) (cd CommonData, err error)
- func (CommonData) Empty() CommonData
- func (cd CommonData) Encode() []byte
- func (cd CommonData) FillNotNil(dest *CommonData)
- func (cd CommonData) Part(roleName string) CommonData
- func (cd CommonData) WithoutRole(roleName string) CommonData
- type Emission
- type EngiCounters
- type EngiData
- type Galaxy
- type GalaxyPoint
- type LogGameEvent
- type NaviData
- type OtherShipData
- type PilotData
- type RBData
- type RBFollower
- type ServerData
- type SessionTime
- type Signature
- type SignatureAtlas
- type SignatureParticle
- type SignatureParticleAtlas
- type SignatureType
- type State
- type StateData
- type TData
- func (d *TData) CalcCurMass() float64
- func (d *TData) Decode()
- func (d *TData) Encode()
- func (d *TData) GetState() State
- func (d *TData) GetStateData() StateData
- func (d *TData) LoadCommonData(src CommonData)
- func (d *TData) MyPartToSend() []byte
- func (d *TData) SetState(state State)
- func (d *TData) SetStateData(stateData StateData)
- func (d *TData) Update(roleName string)
- func (d *TData) WaitDone()
- type WormHole
- type WormHoleDirN
- type WormHoleDirSys
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_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" 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 AddFishHouse ¶
func CalculateEmissions ¶
func ClientLogGame ¶
for clients
func ColorByOwner ¶
func CompanyNameByOwner ¶
func EventToCommand ¶
func GetCurrentWormHoleDirectionN ¶
func GetCurrentWormHoleDirectionN() map[string]WormHoleDirN
func GetWormHoleTarget ¶
func GetWormHolesNs ¶
func GetWormHolesNs() map[int]struct{}
func InitSignatureAtlas ¶
func InitSignatureAtlas()
func InitWormHoles ¶
func InitWormHoles()
func KDev ¶
Возвращает коэффициент нормальной дистрибуций сигма в процентах devProcent 68% попадут в (100-devProcent, 100+devProcent) 95% попадут в (100-2*devProcent, 100+2*devProcent) Отклонения больше 3 сигма ограничиваются
func RequestNewBuilding ¶
func RequestRemoveBuilding ¶
func SetGravityConsts ¶
func SetGravityConsts(G, W float64)
func SetVelDistWarpK ¶
func SetVelDistWarpK(k float64)
func SetWarpGravThreshold ¶
func SetWarpGravThreshold(v float64)
func StartProfile ¶
func StopProfile ¶
func StopProfile(prefix string)
func SumGravityAccWithReport ¶
func UpdateGalaxyAndShip ¶
func WarpGravity ¶
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 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 Building ¶
type CommonData ¶
type CommonData struct { PilotData *PilotData `json:"pd"` EngiData *EngiData `json:"ed"` ServerData *ServerData `json:"sd"` }
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 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 ¶
works with already calced and ordered Galaxy
func (*Galaxy) AddWarpBuilding ¶
works with already calced and ordered Galaxy
func (*Galaxy) DelBuilding ¶
works with already calced and ordered Galaxy
func (*Galaxy) DelWarpBuilding ¶
works with already calced and ordered Galaxy
func (*Galaxy) RecalcLvls ¶
func (galaxy *Galaxy) RecalcLvls()
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 ¶
func (LogGameEvent) Decode ¶
func (LogGameEvent) Decode(data []byte) (res LogGameEvent, err error)
type NaviData ¶
type NaviData struct { int `json:"bc,omitempty"` //[]corpName, i.e. ["gd","gd","pre"] //[]planetName, i.e. ["CV8-85","RD4-42-13"] //cosmo //warp }BeaconCount
type OtherShipData ¶
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 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) Particle ¶
func (s Signature) Particle() SignatureParticle
func (Signature) Type ¶
func (s Signature) Type() SignatureType
type SignatureAtlas ¶
type SignatureAtlas map[string]SignatureType
type SignatureParticle ¶
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 StateData ¶
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 (*TData) CalcCurMass ¶
func (*TData) GetStateData ¶
Network cycle, get data for scene.Init
type WormHoleDirN ¶
type WormHoleDirN struct {
Src, Dest int
}
type WormHoleDirSys ¶
type WormHoleDirSys struct {
Src, Dest string
}
func GetCurrentWormHoleDirectionSys ¶
func GetCurrentWormHoleDirectionSys() []WormHoleDirSys
Click to show internal directories.
Click to hide internal directories.