辐射图刷新错误修复
This commit is contained in:
parent
f4c4ae4ddc
commit
fd2aeb0ce1
|
@ -69,10 +69,33 @@ func (slf *RadiationPattern[ItemType, Item]) Refresh(x, y int, item Item) {
|
||||||
slf.links.Delete(oldGuid)
|
slf.links.Delete(oldGuid)
|
||||||
delete(slf.positions, oldGuid)
|
delete(slf.positions, oldGuid)
|
||||||
|
|
||||||
|
slf.matrix[x][y] = item
|
||||||
slf.positions[item.GetGuid()] = PositionToArray(x, y)
|
slf.positions[item.GetGuid()] = PositionToArray(x, y)
|
||||||
slf.searchNeighbour(x, y, synchronization.NewMap[int64, bool](), synchronization.NewMap[int64, bool]())
|
slf.searchNeighbour(x, y, synchronization.NewMap[int64, bool](), synchronization.NewMap[int64, bool]())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RefreshBySwap 通过交换的方式刷新两个成员的辐射信息
|
||||||
|
func (slf *RadiationPattern[ItemType, Item]) RefreshBySwap(x1, y1, x2, y2 int, item1, item2 Item) {
|
||||||
|
var xys = [][2]int{PositionToArray(x1, y1), PositionToArray(x2, y2)}
|
||||||
|
for _, xy := range xys {
|
||||||
|
x, y := PositionArrayToXY(xy)
|
||||||
|
old := slf.matrix[x][y]
|
||||||
|
oldGuid := old.GetGuid()
|
||||||
|
for linkGuid := range slf.links.Get(oldGuid) {
|
||||||
|
xy := slf.positions[linkGuid]
|
||||||
|
slf.searchNeighbour(xy[0], xy[1], synchronization.NewMap[int64, bool](), synchronization.NewMap[int64, bool]())
|
||||||
|
}
|
||||||
|
slf.links.Delete(oldGuid)
|
||||||
|
delete(slf.positions, oldGuid)
|
||||||
|
}
|
||||||
|
for i, item := range []Item{item1, item2} {
|
||||||
|
x, y := PositionArrayToXY(xys[i])
|
||||||
|
slf.matrix[x][y] = item
|
||||||
|
slf.positions[item.GetGuid()] = PositionToArray(x, y)
|
||||||
|
slf.searchNeighbour(x, y, synchronization.NewMap[int64, bool](), synchronization.NewMap[int64, bool]())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (slf *RadiationPattern[ItemType, Item]) searchNeighbour(x, y int, filter *synchronization.Map[int64, bool], childrenLinks *synchronization.Map[int64, bool]) {
|
func (slf *RadiationPattern[ItemType, Item]) searchNeighbour(x, y int, filter *synchronization.Map[int64, bool], childrenLinks *synchronization.Map[int64, bool]) {
|
||||||
var (
|
var (
|
||||||
item = slf.matrix[x][y]
|
item = slf.matrix[x][y]
|
||||||
|
|
Loading…
Reference in New Issue