summaryrefslogtreecommitdiffstats
path: root/world/monuments/Monument.gd
blob: 86074f1b809458182b6702fb9e40d67701f6a935 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class_name Monument

var xform:Transform = Transform(Basis(),Vector3.ZERO)
var scene:PackedScene = null
var chunks = {}
var origin_chunk = Vector2.ZERO
var loaded_chunk = null

func is_chunk_in_monument(chunk_coords:Vector2):
    return self.chunks.has(chunk_coords)

func _init(transform,scn,member_chunks, origin):
    self.xform = transform
    self.xform.origin = ChunkLoader.v3_coords(ChunkLoader.chunk_coords(ChunkLoader.v2_coords(self.xform.origin)))
    self.scene = scn
    var org = ChunkLoader.chunk_coords(ChunkLoader.v2_coords(self.xform.origin))
    for c in member_chunks.keys():
        var c2 = ChunkLoader.v2_coords(self.xform.basis * ChunkLoader.v3_coords(c))
        self.chunks[ChunkLoader.chunk_coords(c2)+org] = member_chunks[c]
    origin = ChunkLoader.v2_coords(self.xform.basis * ChunkLoader.v3_coords(origin))
    self.origin_chunk = ChunkLoader.chunk_coords(origin)+org