prefabs broken
This commit is contained in:
@ -2,6 +2,7 @@ package gamemap
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/items"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/mob"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
@ -29,14 +30,15 @@ func (r *Room) Put (x, y int, tileFunc interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (room *Room) BlitToLevel(l *Level, where types.Coords) error {
|
||||
func (room *Room) BlitToLevel(l *Level) error {
|
||||
//copy tiles like this:
|
||||
//https://stackoverflow.com/questions/21011023/copy-pointer-values-a-b-in-golang
|
||||
|
||||
for j := 0; j < room.H; j++ {
|
||||
|
||||
for i := 0; i < room.W; i++ {
|
||||
underlyingTile := l.GetTileByXY(i+where.X, j+where.Y)
|
||||
mapCoords := types.Coords{room.X + i, room.Y + j}
|
||||
underlyingTile := l.GetTile(mapCoords)
|
||||
|
||||
tileFunc := room.Geometry[i+j*room.W]
|
||||
|
||||
@ -46,11 +48,17 @@ func (room *Room) BlitToLevel(l *Level, where types.Coords) error {
|
||||
//check underlying tile
|
||||
if underlyingTile == nil ||
|
||||
underlyingTile.Name != "Wall" {
|
||||
fmt.Println("Invalid blit!")
|
||||
return invalidBlit
|
||||
}
|
||||
l.Put(i+where.X, j+where.Y, tileFunc)
|
||||
l.Put(mapCoords.X, mapCoords.Y, tileFunc)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (room *Room) MoveToCoords(where types.Coords) *Room {
|
||||
//update room coords?
|
||||
room.X = where.X
|
||||
room.Y = where.Y
|
||||
@ -62,7 +70,7 @@ func (room *Room) BlitToLevel(l *Level, where types.Coords) error {
|
||||
room.Connectors[i].X += where.X
|
||||
room.Connectors[i].Y += where.Y
|
||||
}
|
||||
return nil
|
||||
return room
|
||||
}
|
||||
|
||||
func NewRandomRectRoom(rng *util.RNG, w, h int, fillage types.RectFill) *Room {
|
||||
|
Reference in New Issue
Block a user