added probe result type
This commit is contained in:
parent
a755d28688
commit
714ea669d2
59
robot.go
59
robot.go
@ -8,28 +8,33 @@ import (
|
||||
)
|
||||
|
||||
type Robot struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Message string `json:"-"`
|
||||
Stats Stats `json:"-"`
|
||||
TargetSpeed float32 `json:"-"`
|
||||
Speed float32 `json:"speed"`
|
||||
Health int `json:"health"`
|
||||
RepairCounter float32 `json:"repair"`
|
||||
ScanCounter float32 `json:"scan_bonus"`
|
||||
ActiveScan bool `json:"-"`
|
||||
Position v.Point2d `json:"position"`
|
||||
Heading v.Vector2d `json:"heading"`
|
||||
DesiredHeading *v.Vector2d `json:"-"`
|
||||
MoveTo *v.Point2d `json:"-"`
|
||||
FireAt *v.Point2d `json:"-"`
|
||||
Scanners []Scanner `json:"scanners"`
|
||||
LastFired int `json:"-"`
|
||||
Collision bool `json:"collision"`
|
||||
Hit bool `json:"hit"`
|
||||
Probe *v.Point2d `json:"probe"`
|
||||
ProbeResult *v.Point2d `json:"probe_result"`
|
||||
gameStats *BotStats `json:-`
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Message string `json:"-"`
|
||||
Stats Stats `json:"-"`
|
||||
TargetSpeed float32 `json:"-"`
|
||||
Speed float32 `json:"speed"`
|
||||
Health int `json:"health"`
|
||||
RepairCounter float32 `json:"repair"`
|
||||
ScanCounter float32 `json:"scan_bonus"`
|
||||
ActiveScan bool `json:"-"`
|
||||
Position v.Point2d `json:"position"`
|
||||
Heading v.Vector2d `json:"heading"`
|
||||
DesiredHeading *v.Vector2d `json:"-"`
|
||||
MoveTo *v.Point2d `json:"-"`
|
||||
FireAt *v.Point2d `json:"-"`
|
||||
Scanners []Scanner `json:"scanners"`
|
||||
LastFired int `json:"-"`
|
||||
Collision bool `json:"collision"`
|
||||
Hit bool `json:"hit"`
|
||||
Probe *v.Point2d `json:"probe"`
|
||||
ProbeResult *ProbeResult `json:"probe_result"`
|
||||
gameStats *BotStats `json:-`
|
||||
}
|
||||
|
||||
type ProbeResult struct {
|
||||
v.Point2d
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// This is the subset of data we send to players about robots
|
||||
@ -370,9 +375,15 @@ func (r *Robot) Tick(g *game) {
|
||||
|
||||
if r.Probe != nil && r.ProbeResult == nil {
|
||||
probe_vector := r.Probe.Sub(r.Position)
|
||||
coll, pos, _ := r.checkCollisions(g, probe_vector)
|
||||
coll, pos, robo := r.checkCollisions(g, probe_vector)
|
||||
if coll {
|
||||
r.ProbeResult = pos
|
||||
r.ProbeResult = &ProbeResult{
|
||||
Point2d: *pos,
|
||||
Type: "obstacle",
|
||||
}
|
||||
if robo != nil {
|
||||
r.ProbeResult.Type = "robot"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user