A little folders cleanup
This commit is contained in:
parent
997e3c0982
commit
545da7be1f
90 changed files with 68 additions and 1661 deletions
65
scripts/Star System/star_system.gd
Normal file
65
scripts/Star System/star_system.gd
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
extends Node
|
||||
|
||||
class_name StarSystem
|
||||
|
||||
@onready var fact_player = $FactionPlayer
|
||||
@onready var fact_peaceful = $FactionPeaceful
|
||||
@onready var fact_neutral = $FactionNeutral
|
||||
@onready var fact_aggressive = $FactionAggressive
|
||||
|
||||
## Width of the system. Limits stars generation and camera bounds
|
||||
@export var width: int = 8192
|
||||
## Height of the system. Limits stars generation and camera bounds
|
||||
@export var height: int = 8192
|
||||
|
||||
## Pause controller packed scene
|
||||
@export var pause_controller_scene: PackedScene
|
||||
|
||||
## Node which is colliding with mouse
|
||||
var targeted_node: Node2D = null
|
||||
|
||||
## Player ship reference. May be null.
|
||||
var player_ship: PlayerShip
|
||||
## Pause controller reference
|
||||
var pause_controller: Control
|
||||
|
||||
func _ready():
|
||||
player_ship = get_node_or_null("FactionPlayer/PlayerShip")
|
||||
|
||||
pause_controller = pause_controller_scene.instantiate()
|
||||
|
||||
if player_ship != null:
|
||||
# adjust player ship camera if player ship exists
|
||||
player_ship.camera.limit_left = -width / 2
|
||||
player_ship.camera.limit_right = width / 2
|
||||
player_ship.camera.limit_top = -height / 2
|
||||
player_ship.camera.limit_bottom = height / 2
|
||||
# add pause controller child to the gui
|
||||
player_ship.colorable_gui.add_child(pause_controller)
|
||||
else:
|
||||
# or add it to root node lol
|
||||
add_child(pause_controller)
|
||||
|
||||
|
||||
pause_controller.visible = false
|
||||
|
||||
## Pause the game. Remember to unpause it when switching scenes!
|
||||
func pause():
|
||||
get_tree().paused = true
|
||||
pause_controller.visible = true
|
||||
|
||||
## Unpause the game.
|
||||
func unpause():
|
||||
get_tree().paused = false
|
||||
pause_controller.visible = false
|
||||
|
||||
func _process(_delta):
|
||||
# pausing
|
||||
if Input.is_action_just_released("pause"):
|
||||
unpause() if get_tree().paused else pause()
|
||||
|
||||
func set_targeted_node(node):
|
||||
targeted_node = node
|
||||
|
||||
func clear_targeted_node():
|
||||
targeted_node = null
|
||||
Loading…
Add table
Add a link
Reference in a new issue