-
Notifications
You must be signed in to change notification settings - Fork 1
/
components.js
91 lines (85 loc) · 2.21 KB
/
components.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { formatNum } from "./mergeComponents.js"
import {
getMergedHull,
getMergedThrust,
getMergedWeapons,
getMergedWings
} from "./ship.js"
import {
renderHull,
renderThrust,
renderWeapons,
renderWings
} from "./ShipRender.js"
import { translateToAndDraw } from "./Util.js"
export const getComponentKeys = () => {
return Object.keys(components).sort((a, b) => (b == "hull" ? -1 : 1))
}
export const getComponentNames = () => {
return Object.keys(components).sort((a, b) => -(a == "hull" ? 1 : 0))
}
export const components = {
weapons: {
name: "Weapons",
stats: {
HP: ship => ship.shipOpts.weapons.maxHp,
"Fire Rate": ship => ship.fireRate,
Damage: ship => ship.dmg,
"Shot Speed": ship => ship.shotSpeed,
Range: ship => ship.shotLife * ship.shotSpeed
},
formatters: {
"Fire Rate": val => formatNum(60 / val, 3),
"Shot Speed": val => formatNum(100 * val, 1)
},
suffixes: {
"Fire Rate": "/s",
"Shot Speed": "km/s"
},
render: (c, opts) => {
translateToAndDraw(c, 0, ((1 / (40 / 5)) * 40) / 5, () =>
renderWeapons(c, opts, 0.5, 0.5)
)
},
getMerged: (curOpts, opts1, opts2, tween) =>
getMergedWeapons(opts1.weapons, opts2.weapons, tween)
},
hull: {
name: "Hull",
stats: {
HP: ship => ship.shipOpts.hull.maxHp
},
render: (c, opts) => renderHull(opts, c, 0.5, 0.5),
getMerged: (curOpts, opts1, opts2, tween) =>
getMergedHull(opts1.hull, opts2.hull, tween)
},
wings: {
name: "Wings",
formatters: {
"Turn Speed": val => formatNum(100 * val, 3)
},
stats: {
HP: ship => ship.shipOpts.wings.maxHp,
"Turn Speed": ship => ship.turnSpeed
},
render: (c, opts) => renderWings(opts, c, 0.5, 0.5),
getMerged: (curOpts, opts1, opts2, tween) =>
getMergedWings(curOpts.hull.h, opts1.wings, opts2.wings, tween)
},
thrust: {
name: "Thrust",
formatters: {
"Thrust Speed": val => formatNum(1000 * val, 3)
},
stats: {
HP: ship => ship.shipOpts.wings.maxHp,
"Thrust Speed": ship => ship.speed
},
render: (c, opts) =>
translateToAndDraw(c, 0, -((1 / (40 / 5)) * 40) / 4, () =>
renderThrust(opts, c, 0.5, 0.5, true)
),
getMerged: (curOpts, opts1, opts2, tween) =>
getMergedThrust(curOpts.hull, opts1.thrust, opts2.thrust, tween)
}
}