summaryrefslogtreecommitdiff
path: root/scripts/HexSpace.gd
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2025-08-19 12:38:02 -0700
committerAnson Bridges <bridges.anson@gmail.com>2025-08-19 12:38:02 -0700
commit255fbf19cc9499ef384d41f68515da5e49e8a3ce (patch)
tree13c838229198383b24644f613787e34842ea7ab2 /scripts/HexSpace.gd
parentf087c6a98b1da55525a6e3c1d7c82477f82eb5cd (diff)
added menus, reworking GC client architecture
Diffstat (limited to 'scripts/HexSpace.gd')
-rw-r--r--scripts/HexSpace.gd86
1 files changed, 64 insertions, 22 deletions
diff --git a/scripts/HexSpace.gd b/scripts/HexSpace.gd
index c8269fd..bcf64f1 100644
--- a/scripts/HexSpace.gd
+++ b/scripts/HexSpace.gd
@@ -1,50 +1,92 @@
tool
extends StaticBody
-var cell_type : String = "normal"
+enum { PLAIN, HILLS, MOUNTAINS, AIRPORT }
+enum { Y, X }
+
+# general cell variables
+var x : int = -1
+var y : int = -1
+var cell_type : int = PLAIN
+var orientation : int = 0 # 0 - 5
# airport variables
var airport_number : int
var airport_color : Color
var airport_id : int
+var airport_name : String
+var runway_count : int
+var airport_closed : bool = false
+
# cell offsets that describe valid approaches based on runways and surroundings
# used to choose a takeoff position
+enum rotations { EAST, NORTHEAST, NORTHWEST, WEST, SOUTHWEST, SOUTHEAST }
const bearings = [ [0,1] , [-1, 0], [-1, -1], [0, -1], [1, 0], [1, 1] ]
-var valid_approaches = []
-var valid_bearings = []
+
+var valid_departure_bearings = []
+var valid_arrival_bearings = []
func _ready():
pass
-func set_up(tile_type, settings={}):
- valid_bearings = [] # reset
- cell_type = tile_type
+func reset():
+ $Hills.visible = false
+ $Mountain.visible = false
+ $Airport.visible = false
+ $Airport/EasyRunway.visible = true # reset runways
+ $Airport/MediumRunway.visible = true
+ $Airport/AirportName.visible = false
+ $Airport/AirportIcon.visible = false
+ orientation = 0
+ self.rotation.y = 0
+ cell_type = PLAIN
+ x = -1
+ y = -1
+ airport_closed = false
+
- if settings["rotation"]: # bearing according to E, NE, etc.
- self.global_rotation.y = settings["rotation"] * deg2rad(60)
+func set_up(settings):
+ x = settings["pos"][X] ; y = settings["pos"][Y]
+ cell_type = settings["cell_type"]
- if tile_type == "hills":
+ valid_departure_bearings.clear()
+ valid_arrival_bearings.clear()
+
+
+ if settings["orientation"]: # bearing according to E, NE, etc.
+ orientation = settings["orientation"]
+ self.global_rotation.y = orientation * deg2rad(60)
+
+ if cell_type == HILLS:
$Hills.visible = true
- elif tile_type == "mountain":
+ elif cell_type == MOUNTAINS:
$Mountain.visible = true
- elif tile_type == "airport":
+ elif cell_type == AIRPORT:
$Airport.visible = true
- airport_number = settings["airport_number"]
- airport_color = settings["airport_color"]
- valid_approaches = settings["valid_approaches"]
- for approach in valid_approaches:
- var bearing_i = bearings.find(approach)
- valid_bearings.push_back(bearings[bearing_i])
+ if settings["use_names"]:
+ airport_name = settings["airport_name"]
+ $Airport/AirportName.visible = true
+ else:
+ airport_number = settings["airport_number"]
+ airport_color = settings["airport_color"]
+ $Airport/AirportIcon.visible = true
+ $Airport/AirportIcon.texture = load("res://textures/airport_indicator_%d.png" % airport_number)
+ $Airport/AirportIcon.modulate = airport_color
+
+ valid_departure_bearings = settings["valid_approach_offsets"]
airport_id = settings["airport_id"]
- $Airport/AirportIcon.texture = load("res://textures/airport_indicator_%d.png" % airport_number)
- $Airport/AirportIcon.modulate = airport_color
+ for departure_bearing in valid_departure_bearings:
+ var bearing_i = bearings.find(departure_bearing)
+ bearing_i = (bearing_i + 3) % 6 # opposite bearing
+ valid_arrival_bearings.push_back(bearings[bearing_i])
- if settings["difficulty"] == "easy": return
- $Airport/EasyRunway.visible = false
- if settings["difficulty"] == "hard":
+ runway_count = int(clamp(settings["runway_count"], 1, 3))
+ if runway_count < 3:
+ $Airport/EasyRunway.visible = false
+ if runway_count == 1:
$Airport/MediumRunway.visible = false