-
Notifications
You must be signed in to change notification settings - Fork 0
/
sun.go
56 lines (44 loc) · 1015 Bytes
/
sun.go
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
package objects
import (
"github.com/dayaftereh/discover/server/game/engine/physics"
"github.com/dayaftereh/discover/server/game/persistence/types"
"github.com/dayaftereh/discover/server/mathf"
)
var GameObjectSun GameObjectType = "sun"
type Sun struct {
id int64
rigidbody *physics.RigidBody
// public
Data *types.Sun
}
func NewSun(id int64, data *types.Sun) *Sun {
return &Sun{
id: id,
Data: data,
rigidbody: physics.NewRigidBody(),
}
}
func (sun *Sun) Init() error {
// setup rigidbody
sun.rigidbody.Mass = sun.Data.Mass
sun.rigidbody.LinearFactor = mathf.NewZeroVec3()
return nil
}
func (sun *Sun) ID() int64 {
return sun.id
}
func (sun *Sun) RigidBody() *physics.RigidBody {
return sun.rigidbody
}
func (sun *Sun) Update(delta float64) {
// update the rigidbody
sun.rigidbody.Update(delta)
}
func (sun *Sun) Type() GameObjectType {
return GameObjectSun
}
func (sun *Sun) Radius() float64 {
return sun.Data.EcosphereRadius
}
func (sun *Sun) Destroy() {
}