14 years
edited 8 years
1 library WorldBounds /* v2.0.0.0
2 ************************************************************************************3 *4 * struct WorldBounds extends array5 *6 * Fields7 * -------------------------8 *9 * readonly static integer maxX10 * readonly static integer maxY11 * readonly static integer minX12 * readonly static integer minY13 *14 * readonly static integer centerX15 * readonly static integer centerY16 *17 * readonly static rect world18 * readonly static region worldRegion19 *20 ************************************************************************************/21 private module WorldBoundInit
22 private static method onInit takes nothing returns nothing
23 set world=GetWorldBounds()
24
25 set maxX = R2I(GetRectMaxX(world))
26 set maxY = R2I(GetRectMaxY(world))
27 set minX = R2I(GetRectMinX(world))
28 set minY = R2I(GetRectMinY(world))
29
30 set centerX = R2I((maxX + minX)/2)
31 set centerY = R2I((minY + maxY)/2)
32
33 set worldRegion = CreateRegion()
34
35 call RegionAddRect(worldRegion, world)
36 endmethod37 endmodule38
39 struct WorldBounds extends array
40 readonly static integer maxX
41 readonly static integer maxY
42 readonly static integer minX
43 readonly static integer minY
44
45 readonly static integer centerX
46 readonly static integer centerY
47
48 readonly static rect world
49
50 readonly static region worldRegion
51
52 implement WorldBoundInit53 endstruct54 endlibrary