debugged delaunay, problem was in referencing slice of connectors instead of copying
This commit is contained in:
@ -11,8 +11,8 @@ import (
|
||||
|
||||
//fixme move to config
|
||||
var minRoomSize = 5
|
||||
var maxRoomSize = 15
|
||||
var maxrooms = 59
|
||||
var maxRoomSize = 25
|
||||
var maxrooms = 200
|
||||
|
||||
var fges = map[int]types.RectFill{
|
||||
1: types.RectFill{
|
||||
@ -58,12 +58,24 @@ func DelaunayMstGen(ctx appctx.ClientCtx, l *gamemap.Level) (*gamemap.Level, []g
|
||||
failed := false
|
||||
var fillage types.RectFill
|
||||
fillage = fges[rng.GetWeightedEntity(map[int]int{1: 10, 2: 1})]
|
||||
var newRoom gamemap.Room
|
||||
var newRoom = gamemap.Room{}
|
||||
if !prefabUsed || rng.Range(0, 5) > 3 {
|
||||
//if prefabUsed {
|
||||
//prefab
|
||||
prefabUsed = true
|
||||
fmt.Printf("\n\n------USING PREFAB-----\n")
|
||||
r := pfRooms[rng.Range(0, len(pfRooms))] //copy to local scope
|
||||
newRoom = r
|
||||
newRoom = gamemap.Room{
|
||||
Rect: r.Rect,
|
||||
Center: r.Center,
|
||||
Geometry: r.Geometry,
|
||||
Items: r.Items,
|
||||
Mobs: r.Mobs,
|
||||
Connectors: make([]types.Coords,0),
|
||||
}
|
||||
for _, coord := range r.Connectors {
|
||||
newRoom.Connectors = append(newRoom.Connectors, coord)
|
||||
}
|
||||
} else {
|
||||
newRoom = gamemap.NewRandomRectRoom(
|
||||
rng,
|
||||
@ -104,8 +116,9 @@ func DelaunayMstGen(ctx appctx.ClientCtx, l *gamemap.Level) (*gamemap.Level, []g
|
||||
for _, room := range rooms {
|
||||
centers = append(centers, room.Center)
|
||||
}
|
||||
|
||||
for _, edge := range delaunay.GetMst(centers, l.W, l.H) {
|
||||
edges := delaunay.GetMst(centers, l.W, l.H)
|
||||
fmt.Printf("edges: ", edges)
|
||||
for _, edge := range edges {
|
||||
MedianStraight(rng, l, rooms, centers, edge)
|
||||
}
|
||||
|
||||
@ -132,6 +145,26 @@ func MedianStraight(rng *util.RNG, l *gamemap.Level, rooms []gamemap.Room, cente
|
||||
midpoint := edge.Midpoint()
|
||||
fromConnector := findNearestCoonector(midpoint, fromRoom)
|
||||
toConnector := findNearestCoonector(midpoint, toRoom)
|
||||
if (!l.InBounds(midpoint)) {
|
||||
//fmt.Printf("rooms: ", rooms)
|
||||
fmt.Printf("\nedges: ", edge)
|
||||
fmt.Printf("\nmidpoint: ", midpoint)
|
||||
panic(fmt.Errorf("midpoint out of level bounds!"))
|
||||
}
|
||||
if (!l.InBounds(fromConnector)) {
|
||||
fmt.Printf("\nfrom room: ", fromRoom.String())
|
||||
fmt.Printf("\nedges: ", edge)
|
||||
fmt.Printf("\nfromConnector: ", fromConnector)
|
||||
panic(fmt.Errorf("fromConnector out of level bounds!"))
|
||||
}
|
||||
|
||||
if (!l.InBounds(toConnector)) {
|
||||
fmt.Printf("\nto room: ", toRoom.String())
|
||||
fmt.Printf("\nedges: ", edge)
|
||||
fmt.Printf("\ntoConnector: ", toConnector)
|
||||
panic(fmt.Errorf("toConnector out of level bounds!"))
|
||||
}
|
||||
|
||||
connectStraight(rng, l, fromConnector, toConnector, midpoint)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user