|
1 | | -// Package metadata provides metadata and utility functions, |
2 | | -// like translations from ingame coordinates to radar image pixels (see also /assets/maps directory). |
3 | | -package parser |
4 | | - |
5 | | -import ( |
6 | | - "github.com/golang/geo/r2" |
7 | | -) |
8 | | - |
9 | | -// MapCS represents a CS:GO map. It contains information required to translate |
10 | | -// in-game world coordinates to coordinates relative to (0, 0) on the provided map-overviews (radar images). |
11 | | -type MapCS struct { |
12 | | - Name string |
13 | | - PZero r2.Point |
14 | | - Scale float64 |
15 | | -} |
16 | | - |
17 | | -// Translate translates in-game world-relative coordinates to (0, 0) relative coordinates. |
18 | | -func (m MapCS) Translate(x, y float64) (float64, float64) { |
19 | | - return x - m.PZero.X, m.PZero.Y - y |
20 | | -} |
21 | | - |
22 | | -// TranslateScale translates and scales in-game world-relative coordinates to (0, 0) relative coordinates. |
23 | | -// The outputs are pixel coordinates for the radar images found in the maps folder. |
24 | | -func (m MapCS) TranslateScale(x, y float64) (float64, float64) { |
25 | | - x, y = m.Translate(x, y) |
26 | | - return x / m.Scale, y / m.Scale |
27 | | -} |
28 | | - |
29 | | -// MapNameToMap translates a map name to a Map. |
30 | | -var MapNameToMap = make(map[string]MapCS) |
31 | | - |
32 | | -// makeMap creates a map stuct initialized with the given parameters. |
33 | | -func makeMap(name string, x, y, scale float64) MapCS { |
34 | | - m := MapCS{Name: name, PZero: r2.Point{X: x, Y: y}, Scale: scale} |
35 | | - |
36 | | - MapNameToMap[name] = m |
37 | | - |
38 | | - return m |
39 | | -} |
40 | | - |
41 | | -// Pre-defined map translations. |
42 | | -// see "steamapps/common/Counter-Strike Global Offensive/csgo/resource/overviews/*.txt" |
43 | | -var ( |
44 | | - MapDeAncient = makeMap("de_ancient", -2953, 2164, 5) |
45 | | - MapDeAnubis = makeMap("de_anubis", -2796, 3328, 5.22) |
46 | | - MapDeCache = makeMap("de_cache", -2000, 3250, 5.5) |
47 | | - MapDeCanals = makeMap("de_canals", -2496, 1792, 4) |
48 | | - MapDeCbble = makeMap("de_cbble", -3840, 3072, 6) |
49 | | - MapDeDust2 = makeMap("de_dust2", -2476, 3239, 4.4) |
50 | | - MapDeInferno = makeMap("de_inferno", -2087, 3870, 4.9) |
51 | | - MapDeMirage = makeMap("de_mirage", -3230, 1713, 5) |
52 | | - MapDeNuke = makeMap("de_nuke", -3453, 2887, 7) |
53 | | - MapDeOverpass = makeMap("de_overpass", -4831, 1781, 5.2) |
54 | | - MapDeTrain = makeMap("de_train", -2477, 2392, 4.7) |
55 | | - MapDeVertigo = makeMap("de_vertigo", -3168, 1762, 4) |
56 | | - MapCsAgency = makeMap("cs_agency", -2947, 2492, 5) |
57 | | - MapCsOffice = makeMap("cs_office", -1838, 1858, 4.1) |
58 | | -) |
| 1 | +// Package metadata provides metadata and utility functions, |
| 2 | +// like translations from ingame coordinates to radar image pixels (see also /assets/maps directory). |
| 3 | +package parser |
| 4 | + |
| 5 | +import ( |
| 6 | + "github.com/golang/geo/r2" |
| 7 | +) |
| 8 | + |
| 9 | +// MapCS represents a CS:GO map. It contains information required to translate |
| 10 | +// in-game world coordinates to coordinates relative to (0, 0) on the provided map-overviews (radar images). |
| 11 | +type MapCS struct { |
| 12 | + Name string |
| 13 | + PZero r2.Point |
| 14 | + Scale float64 |
| 15 | +} |
| 16 | + |
| 17 | +// Translate translates in-game world-relative coordinates to (0, 0) relative coordinates. |
| 18 | +func (m MapCS) Translate(x, y float64) (float64, float64) { |
| 19 | + return x - m.PZero.X, m.PZero.Y - y |
| 20 | +} |
| 21 | + |
| 22 | +// TranslateScale translates and scales in-game world-relative coordinates to (0, 0) relative coordinates. |
| 23 | +// The outputs are pixel coordinates for the radar images found in the maps folder. |
| 24 | +func (m MapCS) TranslateScale(x, y float64) (float64, float64) { |
| 25 | + x, y = m.Translate(x, y) |
| 26 | + return x / m.Scale, y / m.Scale |
| 27 | +} |
| 28 | + |
| 29 | +// MapNameToMap translates a map name to a Map. |
| 30 | +var MapNameToMap = make(map[string]MapCS) |
| 31 | + |
| 32 | +// makeMap creates a map stuct initialized with the given parameters. |
| 33 | +func makeMap(name string, x, y, scale float64) MapCS { |
| 34 | + m := MapCS{Name: name, PZero: r2.Point{X: x, Y: y}, Scale: scale} |
| 35 | + |
| 36 | + MapNameToMap[name] = m |
| 37 | + |
| 38 | + return m |
| 39 | +} |
| 40 | + |
| 41 | +// Pre-defined map translations. |
| 42 | +// see "steamapps/common/Counter-Strike Global Offensive/csgo/resource/overviews/*.txt" |
| 43 | +var ( |
| 44 | + MapDeAncient = makeMap("de_ancient", -2953, 2164, 5) |
| 45 | + MapDeAnubis = makeMap("de_anubis", -2796, 3328, 5.22) |
| 46 | + MapDeCache = makeMap("de_cache", -2000, 3250, 5.5) |
| 47 | + MapDeCanals = makeMap("de_canals", -2496, 1792, 4) |
| 48 | + MapDeCbble = makeMap("de_cbble", -3840, 3072, 6) |
| 49 | + MapDeDust2 = makeMap("de_dust2", -2476, 3239, 4.4) |
| 50 | + MapDeInferno = makeMap("de_inferno", -2087, 3870, 4.9) |
| 51 | + MapDeMirage = makeMap("de_mirage", -3230, 1713, 5) |
| 52 | + MapDeNuke = makeMap("de_nuke", -3453, 2887, 7) |
| 53 | + MapDeOverpass = makeMap("de_overpass", -4831, 1781, 5.2) |
| 54 | + MapDeTrain = makeMap("de_train", -2477, 2392, 4.7) |
| 55 | + MapDeVertigo = makeMap("de_vertigo", -3168, 1762, 4) |
| 56 | + MapCsAgency = makeMap("cs_agency", -2947, 2492, 5) |
| 57 | + MapCsOffice = makeMap("cs_office", -1838, 1858, 4.1) |
| 58 | +) |
0 commit comments