Compose buildings from definitions and capabilities
This commit is contained in:
parent
1721edd123
commit
0504b24d8d
46 changed files with 1091 additions and 878 deletions
|
|
@ -1,20 +1,10 @@
|
|||
extends Node2D
|
||||
|
||||
const PLANET_DEFINITIONS = preload("res://PlanetDefinitions.gd")
|
||||
const BUILDING_DEFINITIONS = preload("res://BuildingDefinitions.gd")
|
||||
|
||||
const WORLD_TO_LOCAL: float = 0.04
|
||||
|
||||
# Mirrors Building.gd's own MOTHERSHIP_COLOR/CRAFTER_COLOR/COMMAND_COLOR so a
|
||||
# marker on the map reads as "the same building" at a glance. Duplicated
|
||||
# rather than cross-referenced - the same colour is already independently
|
||||
# duplicated between Ship.gd, Fleet.gd and Building.gd's HULL_COLOR, so this
|
||||
# follows the codebase's existing convention rather than inventing a new one.
|
||||
const MOTHERSHIP_MARKER_COLOR: Color = Color(0.45, 0.9, 0.55)
|
||||
const CRAFTER_MARKER_COLOR: Color = Color(1.0, 0.72, 0.25)
|
||||
const COMMAND_MARKER_COLOR: Color = Color(0.55, 0.6, 1.0)
|
||||
const TRANSPORT_HUB_MARKER_COLOR: Color = Color(0.95, 0.55, 0.85)
|
||||
const SHIP_LAB_MARKER_COLOR: Color = Color(0.55, 0.95, 0.9)
|
||||
|
||||
# A structure built on a planet's surface (see GameState.extractors) is not
|
||||
# itself a map marker - it is a small badge on the existing planet marker,
|
||||
# in a colour distinct from both the planets and the space buildings so it
|
||||
|
|
@ -40,28 +30,20 @@ func _process(_delta: float) -> void:
|
|||
func building_markers() -> Array:
|
||||
var markers: Array = []
|
||||
for b in GameState.buildings:
|
||||
var definition: Resource = BUILDING_DEFINITIONS.get_definition(String(b.type))
|
||||
if definition == null:
|
||||
continue
|
||||
markers.append({
|
||||
"position": b.position * WORLD_TO_LOCAL,
|
||||
"type": b.type,
|
||||
"color": _building_marker_color(b.type),
|
||||
"color": definition.map_color,
|
||||
"sides": definition.map_sides,
|
||||
"radius": definition.map_radius,
|
||||
"phase": definition.map_phase,
|
||||
})
|
||||
return markers
|
||||
|
||||
|
||||
func _building_marker_color(type: String) -> Color:
|
||||
match type:
|
||||
GameState.BUILDING_MOTHERSHIP:
|
||||
return MOTHERSHIP_MARKER_COLOR
|
||||
GameState.BUILDING_SHIP_CRAFTER:
|
||||
return CRAFTER_MARKER_COLOR
|
||||
GameState.BUILDING_TRANSPORT_HUB:
|
||||
return TRANSPORT_HUB_MARKER_COLOR
|
||||
GameState.BUILDING_SHIP_LAB:
|
||||
return SHIP_LAB_MARKER_COLOR
|
||||
_:
|
||||
return COMMAND_MARKER_COLOR
|
||||
|
||||
|
||||
# Whether the planet in this (explored) chunk has an extractor on it, per
|
||||
# GameState.has_extractor_at(). A separate predicate for the same
|
||||
# GPU-less-testability reason as building_markers().
|
||||
|
|
@ -119,17 +101,7 @@ func _draw() -> void:
|
|||
# Buildings are placed freely in space rather than tied to a chunk, so
|
||||
# they get their own pass rather than living inside the chunk loop above.
|
||||
for marker in building_markers():
|
||||
match marker.type:
|
||||
GameState.BUILDING_MOTHERSHIP:
|
||||
_draw_marker_polygon(_regular_polygon(marker.position, 8.0, 6, PI / 6.0), marker.color)
|
||||
GameState.BUILDING_SHIP_CRAFTER:
|
||||
_draw_marker_polygon(_regular_polygon(marker.position, 7.0, 4, 0.0), marker.color)
|
||||
GameState.BUILDING_TRANSPORT_HUB:
|
||||
_draw_marker_polygon(_regular_polygon(marker.position, 7.5, 8, PI / 8.0), marker.color)
|
||||
GameState.BUILDING_SHIP_LAB:
|
||||
_draw_marker_polygon(_regular_polygon(marker.position, 7.5, 3, -PI / 2.0), marker.color)
|
||||
_:
|
||||
_draw_marker_polygon(_regular_polygon(marker.position, 6.0, 4, PI / 4.0), marker.color)
|
||||
_draw_marker_polygon(_regular_polygon(marker.position, marker.radius, marker.sides, marker.phase), marker.color)
|
||||
|
||||
var fleet_local: Vector2 = fleet.get_centroid() * WORLD_TO_LOCAL
|
||||
var marker_points: PackedVector2Array = PackedVector2Array([
|
||||
|
|
|
|||
Loading…
Reference in a new issue