changes:
- exchanged switch+door sprites - added asesprite cheat sheet - implemented door toggle on switch toggle
This commit is contained in:
12
grid/grid.go
12
grid/grid.go
@@ -8,8 +8,6 @@ import (
|
||||
"openquell/config"
|
||||
"openquell/observers"
|
||||
|
||||
"log/slog"
|
||||
|
||||
"github.com/mlange-42/arche/ecs"
|
||||
"github.com/mlange-42/arche/generic"
|
||||
)
|
||||
@@ -141,16 +139,16 @@ func NewGrid(world *ecs.World,
|
||||
case tile.Switch:
|
||||
entity := switchmapper.New()
|
||||
pos, render, _, switcher = switchmapper.Get(entity)
|
||||
switcher.OpenSprite = tile.Tiles[0]
|
||||
switcher.CloseSprite = tile.Tiles[0]
|
||||
switcher.OpenSprite = tile.Tiles[1]
|
||||
switcher.Ref = tile.Ref
|
||||
switches = append(switches, entity)
|
||||
|
||||
case tile.Door:
|
||||
entity := doormapper.New()
|
||||
pos, render, _, door = doormapper.Get(entity)
|
||||
door.OpenSprite = tile.Tiles[0]
|
||||
door.CloseSprite = tile.Tiles[0]
|
||||
door.OpenSprite = tile.Tiles[1]
|
||||
door.Id = tile.Id
|
||||
doors = append(doors, entity)
|
||||
|
||||
@@ -176,17 +174,19 @@ func NewGrid(world *ecs.World,
|
||||
pos.Update(point.X*tilesize, point.Y*tilesize, tilesize)
|
||||
}
|
||||
|
||||
// check for switch->door references
|
||||
for _, switchentity := range switches {
|
||||
_, _, bond, switcher = switchmapper.Get(switchentity)
|
||||
|
||||
if switcher.Ref != "" {
|
||||
// this switch has a reference
|
||||
for _, doorentity := range doors {
|
||||
_, _, _, door = doormapper.Get(doorentity)
|
||||
if door.Id == switcher.Ref {
|
||||
// the switch reference matches the door id, relate the two
|
||||
bond.Ref = switcher.Ref
|
||||
relID := ecs.ComponentID[components.Bond](world)
|
||||
world.Relations().Set(doorentity, relID, switchentity)
|
||||
slog.Debug("setup switch/door reference")
|
||||
world.Relations().Set(switchentity, relID, doorentity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user