New base menu template
This commit is contained in:
parent
545da7be1f
commit
f2cff37a22
12 changed files with 185 additions and 16 deletions
|
|
@ -2,21 +2,25 @@ extends StaticBody2D
|
|||
|
||||
class_name Base
|
||||
|
||||
enum DockState { Ready, Process, Busy }
|
||||
enum DockState { Ready, Process, Busy, Leave }
|
||||
|
||||
signal dock_requested
|
||||
|
||||
## Reference to star system
|
||||
@onready var star_system: StarSystem = get_tree().current_scene
|
||||
|
||||
## Physical gate
|
||||
@onready var gate_static = $Gate
|
||||
|
||||
## Logical gate for docking
|
||||
@onready var gate_area = $GateArea
|
||||
|
||||
## Docking area
|
||||
@onready var dock_area = $DockingArea
|
||||
|
||||
## Menu which will instantiate on docking
|
||||
@export var menu: PackedScene
|
||||
|
||||
@export var faction: Game.Faction
|
||||
|
||||
## Decides whether ship is docked or in process
|
||||
var dock_state: DockState = DockState.Ready
|
||||
|
||||
var touching_gate = false
|
||||
|
|
@ -66,6 +70,9 @@ func _process(_delta):
|
|||
dock_busy()
|
||||
if !touching_dock and !touching_gate and distance_to_player > 2048:
|
||||
dock_ready()
|
||||
if dock_state == DockState.Leave:
|
||||
if !touching_dock and !touching_gate:
|
||||
dock_ready()
|
||||
|
||||
## Sets dock state to Ready
|
||||
func dock_ready():
|
||||
|
|
@ -74,8 +81,6 @@ func dock_ready():
|
|||
gate_static.process_mode = Node.PROCESS_MODE_INHERIT
|
||||
gate_area.visible = false
|
||||
dock_area.visible = false
|
||||
touching_gate = false
|
||||
touching_dock = false
|
||||
## Sets dock state to Process
|
||||
func dock_process():
|
||||
dock_state = DockState.Process
|
||||
|
|
@ -83,8 +88,6 @@ func dock_process():
|
|||
gate_static.process_mode = Node.PROCESS_MODE_DISABLED
|
||||
gate_area.visible = true
|
||||
dock_area.visible = true
|
||||
touching_gate = false
|
||||
touching_dock = false
|
||||
## Sets dock state to Busy
|
||||
func dock_busy():
|
||||
dock_state = DockState.Busy
|
||||
|
|
@ -92,6 +95,14 @@ func dock_busy():
|
|||
gate_static.process_mode = Node.PROCESS_MODE_INHERIT
|
||||
gate_area.visible = false
|
||||
dock_area.visible = false
|
||||
touching_gate = false
|
||||
touching_dock = true
|
||||
# TODO: implement opening the base menu
|
||||
# opening base menu
|
||||
var menu_instance = menu.instantiate()
|
||||
menu_instance.base = self
|
||||
player_ship.non_colorable_gui.add_child(menu_instance)
|
||||
|
||||
func dock_leave():
|
||||
dock_state = DockState.Leave
|
||||
gate_static.visible = false
|
||||
gate_static.process_mode = Node.PROCESS_MODE_DISABLED
|
||||
gate_area.visible = true
|
||||
dock_area.visible = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue