MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Push

Method Push

contents.go:2269–2323  ·  view source on GitHub ↗
(dx, dy int, loop bool)

Source from the content-addressed store, hash-verified

2267}
2268
2269func (mapData *MapData) Push(dx, dy int, loop bool) {
2270
2271 newData := [][]int{}
2272
2273 for y := 0; y < len(mapData.Data); y++ {
2274 newData = append(newData, []int{})
2275 for x := 0; x < len(mapData.Data[0]); x++ {
2276
2277 var value int
2278
2279 if loop {
2280 // Loop
2281
2282 cy := y - dy
2283 for cy >= len(mapData.Data) {
2284 cy -= len(mapData.Data)
2285 }
2286 for cy < 0 {
2287 cy += len(mapData.Data)
2288 }
2289
2290 cx := x - dx
2291 for cx >= len(mapData.Data[0]) {
2292 cx -= len(mapData.Data[0])
2293 }
2294 for cx < 0 {
2295 cx += len(mapData.Data[0])
2296 }
2297
2298 value = mapData.Data[cy][cx]
2299
2300 } else {
2301
2302 cy := y - dy
2303 cx := x - dx
2304 if cy >= 0 && cy < len(mapData.Data) && cx >= 0 && cx < len(mapData.Data[cy]) {
2305 value = mapData.Data[cy][cx]
2306 }
2307
2308 }
2309
2310 newData[y] = append(newData[y], value)
2311 }
2312 }
2313
2314 mapData.Data = newData
2315
2316 contents := mapData.Contents.Card.Properties.Get("contents")
2317 contents.SetRaw(mapData.Serialize())
2318
2319 mapData.Contents.Card.CreateUndoState = true
2320
2321 mapData.Contents.UpdateTexture()
2322
2323}
2324
2325func (mapData *MapData) Clear() {
2326 for y := 0; y < mapData.Height; y++ {

Callers 3

UpdateMethod · 0.80
ReceiveMessageMethod · 0.80
ConstructMenusFunction · 0.80

Calls 4

SerializeMethod · 0.95
SetRawMethod · 0.80
GetMethod · 0.45
UpdateTextureMethod · 0.45

Tested by

no test coverage detected