GDscript typeees
This commit is contained in:
parent
e977769912
commit
622ea1640d
19 changed files with 255 additions and 250 deletions
|
@ -7,15 +7,15 @@ class_name GameObjectComputer
|
|||
enum Direction { LEFT, RIGHT, UP, DOWN }
|
||||
enum ComputerType { ShipCommand, Comms, Medical, Research, Energy, ShipEngine, Atmos, Monitoring }
|
||||
|
||||
export var object_name = ""
|
||||
export(Direction) var direction = Direction.DOWN setget set_direction
|
||||
export(ComputerType) var computer_type = ComputerType.ShipCommand setget set_type
|
||||
export var object_name := ""
|
||||
export(Direction) var direction := Direction.DOWN setget set_direction
|
||||
export(ComputerType) var computer_type := ComputerType.ShipCommand setget set_type
|
||||
|
||||
var screen_region_offset = Vector2.ZERO
|
||||
var open = false
|
||||
var screen_region_offset := Vector2.ZERO
|
||||
var open := false
|
||||
|
||||
onready var activationRange = $ActivationRange as ActivationRange
|
||||
onready var manager = $PowerManager as PowerManager
|
||||
onready var activationRange := $ActivationRange as ActivationRange
|
||||
onready var manager := $PowerManager as PowerManager
|
||||
|
||||
func _ready():
|
||||
if not Engine.editor_hint:
|
||||
|
|
|
@ -2,18 +2,18 @@ extends StaticBody2D
|
|||
|
||||
class_name GameObjectDoor
|
||||
|
||||
export var object_name = ""
|
||||
export var object_name := ""
|
||||
export(NodePath) var interlockTargetPath
|
||||
var interlockTarget: GameObjectDoor = null
|
||||
|
||||
var open_sound = preload("res://Sounds/SFX/effects/door-open.wav")
|
||||
var close_sound = preload("res://Sounds/SFX/effects/door-close.wav")
|
||||
var open_sound := preload("res://Sounds/SFX/effects/door-open.wav")
|
||||
var close_sound := preload("res://Sounds/SFX/effects/door-close.wav")
|
||||
|
||||
export var idle_usage = 2
|
||||
export var active_usage = 10
|
||||
export var idle_usage := 2
|
||||
export var active_usage := 10
|
||||
|
||||
onready var activationRange = $ActivationRange as ActivationRange
|
||||
onready var manager = $PowerManager as PowerManager
|
||||
onready var activationRange := $ActivationRange as ActivationRange
|
||||
onready var manager := $PowerManager as PowerManager
|
||||
|
||||
signal changed(open)
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ class_name ElectricSocket
|
|||
enum Direction { LEFT, RIGHT, UP, DOWN }
|
||||
enum Flow { SOURCE, SINK, BIDIRECTIONAL }
|
||||
|
||||
export(Direction) var direction = Direction.DOWN setget set_direction
|
||||
export(Direction) var direction := Direction.DOWN setget set_direction
|
||||
|
||||
export(Array, NodePath) var connectionPaths = []
|
||||
var connections = []
|
||||
export(Array, NodePath) var connectionPaths := []
|
||||
var connections := []
|
||||
|
||||
export(Color) var source_color
|
||||
export(Color) var sink_color
|
||||
|
@ -31,7 +31,7 @@ func _ready() -> void:
|
|||
add_connection(get_node(connection))
|
||||
|
||||
func add_connection(node: Node) -> void:
|
||||
var manager = node.get_node("PowerManager") as PowerManager
|
||||
var manager := node.get_node("PowerManager") as PowerManager
|
||||
manager.socket = self
|
||||
connections.append(manager)
|
||||
|
||||
|
@ -64,7 +64,7 @@ func refresh_sprite() -> void:
|
|||
socket.material.set_shader_param("cable_color", bidirectional_color)
|
||||
|
||||
func serialize():
|
||||
var connection_paths = []
|
||||
var connection_paths := []
|
||||
for conn in connections:
|
||||
connection_paths.append({ "path": get_path_to(conn), "powered": conn.powered })
|
||||
|
||||
|
@ -78,7 +78,7 @@ func deserialize(data):
|
|||
set_direction(data["direction"])
|
||||
set_flow(data["flow"])
|
||||
for node in data["connections"]:
|
||||
var manager = get_node(node.path) as PowerManager
|
||||
var manager := get_node(node.path) as PowerManager
|
||||
manager.socket = self
|
||||
manager.powered = node.powered
|
||||
connections.append(manager)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
extends Node2D
|
||||
|
||||
var base_hp = 100.0
|
||||
var base_hp := 100.0
|
||||
|
||||
var damage = 0.0
|
||||
var damage := 0.0
|
||||
|
||||
func get_health() -> float:
|
||||
return base_hp - damage
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
const BASE_SPEED = 300.0
|
||||
const EPSILON = 0.1
|
||||
const MAX_STAMINA = 3.0
|
||||
const BOOST_COEFF = 50.0
|
||||
const STAMINA_RECOVER_RATE = 0.3
|
||||
const NET_KEY_TRANSFORM_DELAY = 0.2
|
||||
const BASE_SPEED := 300.0
|
||||
const EPSILON := 0.1
|
||||
const MAX_STAMINA := 3.0
|
||||
const BOOST_COEFF := 50.0
|
||||
const STAMINA_RECOVER_RATE := 0.3
|
||||
const NET_KEY_TRANSFORM_DELAY := 0.2
|
||||
|
||||
var velocity = Vector2.ZERO
|
||||
var grip = 1.0
|
||||
var stamina = MAX_STAMINA
|
||||
var speed_boost = 0
|
||||
var transform_update_remaining = 0.0
|
||||
var velocity := Vector2.ZERO
|
||||
var grip := 1.0
|
||||
var stamina := MAX_STAMINA
|
||||
var speed_boost := 0
|
||||
var transform_update_remaining := 0.0
|
||||
|
||||
puppet var pup_motion = Vector2.ZERO
|
||||
puppet var pup_velocity = Vector2.ZERO
|
||||
puppet var pup_transform = Transform()
|
||||
puppet var pup_motion := Vector2.ZERO
|
||||
puppet var pup_velocity := Vector2.ZERO
|
||||
puppet var pup_transform := Transform()
|
||||
|
||||
onready var scene = $"/root/scene"
|
||||
onready var world = $"/root/scene/world"
|
||||
onready var camera = $Camera
|
||||
onready var netgame = $"/root/Multiplayer"
|
||||
onready var scene := $"/root/scene"
|
||||
onready var world := $"/root/scene/world"
|
||||
onready var camera := $Camera
|
||||
onready var netgame := $"/root/Multiplayer"
|
||||
|
||||
export var is_controlled = false setget set_is_controlled
|
||||
export var is_controlled := false setget set_is_controlled
|
||||
|
||||
var object_name setget ,get_name
|
||||
|
||||
|
@ -30,7 +30,7 @@ func _ready():
|
|||
$Camera.current = is_controlled
|
||||
|
||||
func _physics_process(delta):
|
||||
var motion = Vector2.ZERO
|
||||
var motion := Vector2.ZERO
|
||||
if is_network_master():
|
||||
if not scene.writing:
|
||||
motion = Vector2(
|
||||
|
@ -38,7 +38,7 @@ func _physics_process(delta):
|
|||
Input.get_action_strength("ui_down")-Input.get_action_strength("ui_up"))
|
||||
|
||||
# Check sprinting
|
||||
var speed = BASE_SPEED
|
||||
var speed := BASE_SPEED
|
||||
if Input.is_action_pressed("sprint") and not scene.writing:
|
||||
if motion.length() > EPSILON and stamina > 0:
|
||||
speed_boost += BOOST_COEFF * delta * ease(stamina/MAX_STAMINA, 1.1)
|
||||
|
@ -93,10 +93,10 @@ func _draw():
|
|||
draw_circle_arc_poly(Vector2(-10, -30), 6, 0, stamina/MAX_STAMINA * 360, Color.orange)
|
||||
|
||||
func draw_circle_arc_poly(center, radius, angle_from, angle_to, color):
|
||||
var nb_points = 32
|
||||
var points_arc = PoolVector2Array()
|
||||
var nb_points := 32
|
||||
var points_arc := PoolVector2Array()
|
||||
points_arc.push_back(center)
|
||||
var colors = PoolColorArray([color])
|
||||
var colors := PoolColorArray([color])
|
||||
|
||||
for i in range(nb_points + 1):
|
||||
var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90)
|
||||
|
@ -107,7 +107,7 @@ func get_info():
|
|||
return netgame.player_info[get_network_master()]
|
||||
|
||||
func get_name():
|
||||
var id = get_network_master()
|
||||
var id := get_network_master()
|
||||
return netgame.player_info[id].name
|
||||
|
||||
func inspect():
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
class_name Coordinates
|
||||
|
||||
static func as_string(coord: Vector2, include_subcoord: bool = false) -> String:
|
||||
var x = floor(coord.x)
|
||||
var y = floor(coord.y)
|
||||
var main = as_string_parts(coord)
|
||||
var sector_name = main[0] + main[1]
|
||||
var x := floor(coord.x)
|
||||
var y := floor(coord.y)
|
||||
var main := as_string_parts(coord)
|
||||
var sector_name := str(main[0]) + str(main[1])
|
||||
if include_subcoord:
|
||||
sector_name += ".%02d/%02d" % [(coord.x - x) * 100, (coord.y - y) * 100]
|
||||
return sector_name
|
||||
|
||||
static func as_string_parts(coord: Vector2) -> Array:
|
||||
var x = floor(coord.x)
|
||||
var y = floor(coord.y)
|
||||
var x_str = to_letter(int(x))
|
||||
var y_str = ""
|
||||
var x := floor(coord.x)
|
||||
var y := floor(coord.y)
|
||||
var x_str := to_letter(int(x))
|
||||
var y_str := ""
|
||||
if y < 0:
|
||||
y_str = to_letter(int(y))
|
||||
else:
|
||||
|
@ -23,15 +23,15 @@ static func as_string_parts(coord: Vector2) -> Array:
|
|||
|
||||
static func to_letter(num: int) -> String:
|
||||
#var letters = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
|
||||
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
var letters := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
if num == 0:
|
||||
return "Α"
|
||||
elif num < 0:
|
||||
letters = "αβγδεζηθικλμνξοπρστυφχψω"
|
||||
if num < 0:
|
||||
num = -num
|
||||
var out = ""
|
||||
var base = letters.length()
|
||||
var out := ""
|
||||
var base := letters.length()
|
||||
while num > 0:
|
||||
out = letters.substr(num % base, 1) + out
|
||||
num /= base
|
||||
|
|
|
@ -4,13 +4,13 @@ class_name GameInstance
|
|||
|
||||
signal state_received()
|
||||
|
||||
onready var ui = $CanvasLayer/ui
|
||||
onready var world = $world
|
||||
onready var systems = $systems
|
||||
onready var netgame = $"/root/Multiplayer"
|
||||
onready var physics = world.get_world_2d().direct_space_state as Physics2DDirectSpaceState
|
||||
onready var ui := $CanvasLayer/ui
|
||||
onready var world := $world as GameWorld
|
||||
onready var systems := $systems as GameSystems
|
||||
onready var netgame := $"/root/Multiplayer"
|
||||
onready var physics := world.get_world_2d().direct_space_state as Physics2DDirectSpaceState
|
||||
|
||||
var writing = false
|
||||
var writing := false
|
||||
|
||||
func _ready() -> void:
|
||||
$"/root/Music/BGM".stop()
|
||||
|
@ -27,9 +27,9 @@ func _ready() -> void:
|
|||
rpc_id(1, "ready_to_spawn")
|
||||
|
||||
master func send_map() -> void:
|
||||
var id = get_tree().get_rpc_sender_id()
|
||||
var map_data = world.map.serialize()
|
||||
var systems_data = systems.serialize()
|
||||
var id := get_tree().get_rpc_sender_id()
|
||||
var map_data := (world.map as GameMap).serialize()
|
||||
var systems_data := systems.serialize()
|
||||
print("sending map data to %d" % id)
|
||||
rpc_id(id, "receive_data", {
|
||||
"map": map_data,
|
||||
|
@ -43,11 +43,11 @@ puppet func receive_data(data: Dictionary) -> void:
|
|||
emit_signal("state_received")
|
||||
|
||||
master func ready_to_spawn() -> void:
|
||||
var id = get_tree().get_rpc_sender_id()
|
||||
var id := get_tree().get_rpc_sender_id()
|
||||
print("%d is ready to spawn players" % id)
|
||||
|
||||
# Tell him everyone to spawn
|
||||
var players = $world/players.get_children()
|
||||
var players := $world/players.get_children()
|
||||
for player in players:
|
||||
rpc_id(id, "spawn_player", player.get_network_master())
|
||||
|
||||
|
@ -55,15 +55,15 @@ master func ready_to_spawn() -> void:
|
|||
rpc("spawn_player", id)
|
||||
|
||||
master func broadcast_zone(message: String, origin: Vector2, radius: float) -> void:
|
||||
var shape = CircleShape2D.new()
|
||||
var shape := CircleShape2D.new()
|
||||
shape.radius = radius
|
||||
var query = Physics2DShapeQueryParameters.new()
|
||||
var query := Physics2DShapeQueryParameters.new()
|
||||
query.collide_with_areas = true
|
||||
query.collide_with_bodies = false
|
||||
query.collision_layer = 32
|
||||
query.transform.origin = origin
|
||||
query.set_shape(shape)
|
||||
var res = physics.intersect_shape(query, 100)
|
||||
var res := physics.intersect_shape(query, 100)
|
||||
for col in res:
|
||||
rpc_id(col.collider.get_network_master(), "add_log", message)
|
||||
|
||||
|
|
|
@ -4,32 +4,32 @@ signal ms_updated(action, data)
|
|||
signal left()
|
||||
|
||||
# Hosting info
|
||||
const SERVER_PORT = 5513
|
||||
const MAX_PLAYERS = 30
|
||||
var port = SERVER_PORT
|
||||
const SERVER_PORT := 5513
|
||||
const MAX_PLAYERS := 30
|
||||
var port := SERVER_PORT
|
||||
|
||||
# Throttle network updates of often-changed variables by this many physics frames
|
||||
const SYSTEMS_UPDATE_INTERVAL = 10
|
||||
const SYSTEMS_UPDATE_INTERVAL := 10
|
||||
|
||||
# Master server data
|
||||
const MASTER_SERVER_ADDR = "fgms.zyg.ovh"
|
||||
const MASTER_SERVER_UDP_PORT = 9434
|
||||
const MS_GAME_CODE = "odyssey-0-a2"
|
||||
const GOTM_OVERRIDE = false
|
||||
const MASTER_SERVER_ADDR := "fgms.zyg.ovh"
|
||||
const MASTER_SERVER_UDP_PORT := 9434
|
||||
const MS_GAME_CODE := "odyssey-0-a2"
|
||||
const GOTM_OVERRIDE := false
|
||||
|
||||
# Master server entry
|
||||
var ms_active = false
|
||||
var ms_key = ""
|
||||
var server_name = ""
|
||||
var ms_active := false
|
||||
var ms_key := ""
|
||||
var server_name := ""
|
||||
|
||||
var hosting = false
|
||||
var hosting := false
|
||||
|
||||
export var player_name = ""
|
||||
export var player_name := ""
|
||||
|
||||
var player_info = {}
|
||||
var round_info = {}
|
||||
var player_info := {}
|
||||
var round_info := {}
|
||||
|
||||
onready var scene_manager = $"/root/SceneManager"
|
||||
onready var scene_manager := $"/root/SceneManager"
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
@ -62,7 +62,7 @@ func punch_nat():
|
|||
socketUDP.close()
|
||||
|
||||
func discover_upnp():
|
||||
var upnp = UPNP.new()
|
||||
var upnp := UPNP.new()
|
||||
upnp.discover(2000, 2, "InternetGatewayDevice")
|
||||
return upnp.add_port_mapping(SERVER_PORT)
|
||||
|
||||
|
@ -86,9 +86,9 @@ func host(map_name: String = "odyssey"):
|
|||
round_info = { "map": map_name }
|
||||
|
||||
bind_events()
|
||||
var peer = NetworkedMultiplayerENet.new()
|
||||
var peer := NetworkedMultiplayerENet.new()
|
||||
peer.compression_mode = NetworkedMultiplayerENet.COMPRESS_FASTLZ
|
||||
var server_res = peer.create_server(port, MAX_PLAYERS)
|
||||
var server_res := peer.create_server(port, MAX_PLAYERS)
|
||||
if server_res != OK:
|
||||
match server_res:
|
||||
ERR_CANT_CREATE:
|
||||
|
@ -127,7 +127,7 @@ func join(server):
|
|||
print("Connecting to %s" % addr)
|
||||
|
||||
func leave():
|
||||
var peer = get_tree().network_peer
|
||||
var peer := get_tree().network_peer
|
||||
if get_tree().is_network_server():
|
||||
# Tell MS we're leaving
|
||||
if ms_active:
|
||||
|
@ -160,7 +160,7 @@ func _connected_fail():
|
|||
push_warning("Connection failed")
|
||||
|
||||
remote func register_player(username: String):
|
||||
var id = get_tree().get_rpc_sender_id()
|
||||
var id := get_tree().get_rpc_sender_id()
|
||||
player_info[id] = { name=username }
|
||||
print("%s (%d) connected" % [player_info[id].name, id])
|
||||
|
||||
|
@ -169,7 +169,7 @@ remote func _handshake(infos):
|
|||
player_info = infos["players"]
|
||||
|
||||
func _ms_request(endpoint: String, data):
|
||||
var http_request = HTTPRequest.new()
|
||||
var http_request := HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
http_request.connect("request_completed", self, "_ms_response", [endpoint])
|
||||
print_debug("Telling ms to %s" % endpoint)
|
||||
|
@ -181,7 +181,7 @@ func _ms_request(endpoint: String, data):
|
|||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
func ms_get_entries():
|
||||
var http_request = HTTPRequest.new()
|
||||
var http_request := HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
http_request.connect("request_completed", self, "_ms_response", ["list_games"])
|
||||
var error = http_request.request(
|
||||
|
@ -226,7 +226,7 @@ func _ms_response(_result: int, response_code: int, _headers: PoolStringArray, b
|
|||
if response_code > 299:
|
||||
push_error("ms action '%s' returned error: %s - %s" % [action, response_code, body.get_string_from_utf8()])
|
||||
return
|
||||
var json = JSON.parse(body.get_string_from_utf8())
|
||||
var json := JSON.parse(body.get_string_from_utf8())
|
||||
match action:
|
||||
"new":
|
||||
if json.result.ok:
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
extends Node2D
|
||||
|
||||
var debug_areas = false
|
||||
var debug_areas := false
|
||||
|
||||
const ProbeElectricity = preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
|
||||
const ProbeElectricity := preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
|
||||
|
||||
onready var tilemaps = [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
|
||||
onready var tilemaps := [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
|
||||
|
||||
onready var pois = $pois
|
||||
onready var pois := $pois
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
@ -19,15 +19,15 @@ func _ready():
|
|||
# Tileset related functions
|
||||
|
||||
func make_electric_probes(tilemap: TileMap, tile_name: String):
|
||||
var tile_id = tilemap.tile_set.find_tile_by_name(tile_name)
|
||||
var tile_id := tilemap.tile_set.find_tile_by_name(tile_name)
|
||||
for cell in tilemap.get_used_cells_by_id(tile_id):
|
||||
var coord = tilemap.map_to_world(cell)
|
||||
var probe = ProbeElectricity.instance()
|
||||
var coord := tilemap.map_to_world(cell)
|
||||
var probe := ProbeElectricity.instance()
|
||||
probe.position = coord
|
||||
tilemap.add_child(probe)
|
||||
|
||||
func get_pois(type_filter, class_filter) -> Array:
|
||||
var filtered = []
|
||||
var filtered := []
|
||||
for child in $pois.get_children():
|
||||
if type_filter != null and child.poitype != type_filter:
|
||||
continue
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extends Control
|
||||
|
||||
onready var text = $BottomRight/Label
|
||||
onready var scene_manager = $"/root/SceneManager"
|
||||
onready var text := $BottomRight/Label
|
||||
onready var scene_manager := $"/root/SceneManager"
|
||||
|
||||
func _physics_process(_delta):
|
||||
text.text = str(scene_manager.get_progress())
|
||||
|
|
100
Scenes/Map.gd
100
Scenes/Map.gd
|
@ -3,44 +3,44 @@ extends Node2D
|
|||
|
||||
class_name GameMap
|
||||
|
||||
var debug_areas = false
|
||||
var debug_areas := false
|
||||
|
||||
var ship_direction = 0
|
||||
var ship_speed = 0
|
||||
var ship_direction := 0
|
||||
var ship_speed := 0
|
||||
|
||||
var current_ship_position = Vector2.ZERO
|
||||
var current_ship_subpos = Vector2.ZERO
|
||||
var current_ship_position := Vector2.ZERO
|
||||
var current_ship_subpos := Vector2.ZERO
|
||||
var current_ship_target = Vector2.ZERO
|
||||
|
||||
var current_ship_direction = 0.0
|
||||
var current_ship_speed = 0.0
|
||||
var current_ship_direction := 0.0
|
||||
var current_ship_speed := 0.0
|
||||
|
||||
var deepspace_mat: ShaderMaterial = null
|
||||
var warp_state = false
|
||||
var warp_state := false
|
||||
|
||||
puppet var pup_ship_position = Vector2.ZERO
|
||||
puppet var pup_ship_subpos = Vector2.ZERO
|
||||
puppet var pup_ship_target = Vector2.ZERO
|
||||
puppet var pup_ship_direction = 0.0
|
||||
puppet var pup_ship_speed = 0.0
|
||||
puppet var pup_ship_position := Vector2.ZERO
|
||||
puppet var pup_ship_subpos := Vector2.ZERO
|
||||
puppet var pup_ship_target := Vector2.ZERO
|
||||
puppet var pup_ship_direction := 0.0
|
||||
puppet var pup_ship_speed := 0.0
|
||||
|
||||
const MAX_ACCELERATION = 0.03
|
||||
const MAX_STEERING = 0.06
|
||||
const EPSILON = 1e-3
|
||||
const SCROLL_MULTIPLIER = 1e4
|
||||
const ENGINE_MULTIPLIER = 5000
|
||||
const NO_SPEED_THRESHOLD = 0.01
|
||||
const MAX_ACCELERATION := 0.03
|
||||
const MAX_STEERING := 0.06
|
||||
const EPSILON := 1e-3
|
||||
const SCROLL_MULTIPLIER := 1e4
|
||||
const ENGINE_MULTIPLIER := 5000
|
||||
const NO_SPEED_THRESHOLD := 0.01
|
||||
|
||||
const ProbeElectricity = preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
|
||||
const ProbeElectricity := preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
|
||||
|
||||
onready var tilemaps = [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
|
||||
onready var tilemaps := [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
|
||||
|
||||
onready var pois = $pois
|
||||
onready var pois := $pois
|
||||
|
||||
export var unlit = false setget set_unlit
|
||||
onready var darkness = $darkness
|
||||
export var unlit := false setget set_unlit
|
||||
onready var darkness := $darkness
|
||||
|
||||
export var shadow_intensity = 0.2
|
||||
export var shadow_intensity := 0.2
|
||||
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
|
@ -65,13 +65,13 @@ func _process(delta: float):
|
|||
if Engine.editor_hint:
|
||||
return
|
||||
|
||||
var engines = get_engine_count()
|
||||
var max_speed = get_max_speed()
|
||||
var engines := get_engine_count()
|
||||
var max_speed := get_max_speed()
|
||||
|
||||
# Ease ship speed/direction changes
|
||||
if abs(current_ship_direction) > PI*2:
|
||||
current_ship_direction -= PI*2 * sign(current_ship_direction)
|
||||
var direction_delta = ship_direction - current_ship_direction
|
||||
var direction_delta := ship_direction - current_ship_direction
|
||||
if direction_delta < 0:
|
||||
direction_delta += PI*2
|
||||
if direction_delta > PI:
|
||||
|
@ -83,7 +83,7 @@ func _process(delta: float):
|
|||
# Avoid stuttering by not turning until there's enough reason to
|
||||
if abs(direction_delta) > 0.1:
|
||||
current_ship_direction += MAX_STEERING * engines * delta * sign(direction_delta)
|
||||
var speed_delta = ship_speed - current_ship_speed
|
||||
var speed_delta := ship_speed - current_ship_speed
|
||||
if abs(speed_delta) < EPSILON:
|
||||
current_ship_speed = ship_speed
|
||||
else:
|
||||
|
@ -96,12 +96,12 @@ func _physics_process(delta):
|
|||
if Engine.editor_hint:
|
||||
return
|
||||
if is_network_master():
|
||||
var adj_position = current_ship_position+current_ship_subpos
|
||||
var adj_position := current_ship_position+current_ship_subpos
|
||||
if current_ship_target != null:
|
||||
var distance = adj_position.distance_to(current_ship_target)
|
||||
var distance := adj_position.distance_to(current_ship_target)
|
||||
if distance > NO_SPEED_THRESHOLD:
|
||||
ship_direction = current_ship_target.angle_to_point(adj_position)
|
||||
var max_speed = get_max_speed()
|
||||
var max_speed := get_max_speed()
|
||||
if max_speed > 0:
|
||||
var deceleration_time = current_ship_speed / (MAX_ACCELERATION * max_speed)
|
||||
if current_ship_speed * deceleration_time < distance:
|
||||
|
@ -116,14 +116,14 @@ func _physics_process(delta):
|
|||
ship_speed = 0.0
|
||||
rset("pup_ship_speed", ship_speed)
|
||||
if current_ship_speed > EPSILON:
|
||||
var pos_delta = (Vector2.RIGHT * current_ship_speed * delta).rotated(current_ship_direction)
|
||||
var pos_delta: Vector2 = (Vector2.RIGHT * current_ship_speed * delta).rotated(current_ship_direction)
|
||||
current_ship_subpos += pos_delta
|
||||
if current_ship_subpos.x >= 1.0:
|
||||
var int_part = floor(current_ship_subpos.x)
|
||||
var int_part := floor(current_ship_subpos.x)
|
||||
current_ship_position.x += int_part
|
||||
current_ship_subpos.x -= int_part
|
||||
if current_ship_subpos.y >= 1.0:
|
||||
var int_part = floor(current_ship_subpos.y)
|
||||
var int_part := floor(current_ship_subpos.y)
|
||||
current_ship_position.y += int_part
|
||||
current_ship_subpos.y -= int_part
|
||||
rset("pup_ship_position", current_ship_position)
|
||||
|
@ -143,18 +143,18 @@ func _physics_process(delta):
|
|||
current_ship_position = pup_ship_position
|
||||
current_ship_subpos = pup_ship_subpos
|
||||
|
||||
func get_engine_count():
|
||||
var working_engines = 0
|
||||
func get_engine_count() -> int:
|
||||
var working_engines := 0
|
||||
for child in $engines.get_children():
|
||||
var engine = child as GameObjectEngine
|
||||
var engine := child as GameObjectEngine
|
||||
if engine.force > 0:
|
||||
working_engines += 1
|
||||
return working_engines
|
||||
|
||||
func get_max_speed():
|
||||
var max_speed = 0
|
||||
func get_max_speed() -> float:
|
||||
var max_speed := 0.0
|
||||
for child in $engines.get_children():
|
||||
var engine = child as GameObjectEngine
|
||||
var engine := child as GameObjectEngine
|
||||
max_speed += engine.force
|
||||
return max_speed
|
||||
|
||||
|
@ -162,9 +162,9 @@ func get_max_speed():
|
|||
|
||||
func serialize() -> Dictionary:
|
||||
# Get tilemap data
|
||||
var tilemapdata = {}
|
||||
var tilemapdata := {}
|
||||
for tilemap in tilemaps:
|
||||
var data = []
|
||||
var data := []
|
||||
for cell in tilemap.get_used_cells():
|
||||
data.append([cell, tilemap.get_cellv(cell)])
|
||||
tilemapdata[tilemap.name] = data
|
||||
|
@ -217,7 +217,7 @@ func deserialize(data: Dictionary) -> void:
|
|||
$tiles/walls.run_conversions()
|
||||
|
||||
func serialize_children(node: Node) -> Dictionary:
|
||||
var data = {}
|
||||
var data := {}
|
||||
for child in node.get_children():
|
||||
data[child.name] = {
|
||||
"filename": child.filename,
|
||||
|
@ -228,7 +228,7 @@ func serialize_children(node: Node) -> Dictionary:
|
|||
|
||||
func deserialize_children(node: Node, data: Dictionary, deserialize_first: bool = false) -> void:
|
||||
for node_name in data:
|
||||
var node_data = data[node_name] as Dictionary
|
||||
var node_data := data[node_name] as Dictionary
|
||||
var node_scene = load(node_data.filename).instance()
|
||||
node_scene.name = node_name
|
||||
node_scene.transform = node_data.transform
|
||||
|
@ -251,7 +251,7 @@ func set_engine_strength(val: float):
|
|||
# Set energy strength to current speed
|
||||
for child in $engines.get_children():
|
||||
if child is GameObjectEngine:
|
||||
var engine = child as GameObjectEngine
|
||||
var engine := child as GameObjectEngine
|
||||
engine.strength = val
|
||||
|
||||
remotesync func warp_enter():
|
||||
|
@ -265,15 +265,15 @@ remotesync func warp_exit():
|
|||
# Tileset related functions
|
||||
|
||||
func make_electric_probes(tilemap: TileMap, tile_name: String):
|
||||
var tile_id = tilemap.tile_set.find_tile_by_name(tile_name)
|
||||
var tile_id := tilemap.tile_set.find_tile_by_name(tile_name)
|
||||
for cell in tilemap.get_used_cells_by_id(tile_id):
|
||||
var coord = tilemap.map_to_world(cell)
|
||||
var probe = ProbeElectricity.instance()
|
||||
var coord := tilemap.map_to_world(cell)
|
||||
var probe := ProbeElectricity.instance()
|
||||
probe.position = coord
|
||||
tilemap.add_child(probe)
|
||||
|
||||
func get_pois(type_filter, class_filter) -> Array:
|
||||
var filtered = []
|
||||
var filtered := []
|
||||
for child in $pois.get_children():
|
||||
if type_filter != null and child.poitype != type_filter:
|
||||
continue
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
[gd_scene load_steps=19 format=2]
|
||||
[gd_scene load_steps=18 format=2]
|
||||
|
||||
[ext_resource path="res://Graphics/tgstation/walls.tres" type="TileSet" id=1]
|
||||
[ext_resource path="res://Graphics/tgstation/1x1.tres" type="TileSet" id=2]
|
||||
[ext_resource path="res://Scenes/Rendering/MapTiles.gd" type="Script" id=3]
|
||||
[ext_resource path="res://Actors/Objects/Door/Door.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Scenes/Map.gd" type="Script" id=5]
|
||||
|
@ -123,14 +122,6 @@ occluder_light_mask = -2147483647
|
|||
format = 1
|
||||
tile_data = PoolIntArray( -655359, 3, 0, -655357, 3, 0, -655355, 3, 0, -655353, 3, 0, -524309, 2, 0, -524308, 2, 0, -524307, 2, 0, -524306, 2, 0, -524305, 2, 0, -524304, 2, 0, -524303, 2, 0, -524302, 2, 0, -524301, 2, 0, -524300, 2, 0, -524299, 2, 0, -524298, 2, 0, -524297, 2, 0, -524296, 2, 0, -524295, 2, 0, -524294, 2, 0, -524293, 2, 0, -524292, 2, 0, -524291, 2, 0, -524290, 2, 0, -524289, 2, 0, -589824, 2, 0, -589823, 3, 0, -589821, 3, 0, -589819, 3, 0, -589817, 3, 0, -458773, 2, 0, -524288, 2, 0, -524287, 3, 0, -524285, 3, 0, -524284, 2, 0, -524283, 3, 0, -524281, 3, 0, -393243, 2, 0, -393242, 3, 0, -393241, 3, 0, -393240, 2, 0, -393239, 2, 0, -393238, 2, 0, -393237, 2, 0, -458752, 2, 0, -458751, 2, 0, -458745, 2, 0, -458744, 2, 0, -458743, 2, 0, -458742, 2, 0, -458741, 2, 0, -458740, 2, 0, -458739, 2, 0, -458738, 2, 0, -458737, 2, 0, -458736, 2, 0, -458735, 2, 0, -458734, 2, 0, -458733, 2, 0, -327707, 2, 0, -327701, 2, 0, -393215, 2, 0, -393209, 3, 0, -393197, 2, 0, -262171, 2, 0, -262165, 2, 0, -327679, 2, 0, -327661, 2, 0, -196638, 2, 0, -196637, 2, 0, -196636, 2, 0, -196635, 2, 0, -196629, 2, 0, -262144, 2, 0, -262143, 2, 0, -262142, 3, 0, -262140, 2, 0, -262138, 3, 0, -262137, 2, 0, -262136, 2, 0, -262125, 2, 0, -262124, 2, 0, -262123, 3, 0, -262122, 2, 0, -262121, 2, 0, -262120, 3, 0, -131102, 2, 0, -131094, 2, 0, -131093, 2, 0, -131073, 2, 0, -196608, 2, 0, -196600, 2, 0, -196589, 2, 0, -196584, 3, 0, -196583, 3, 0, -196582, 3, 0, -196581, 3, 0, -65566, 2, 0, -65558, 2, 0, -65557, 2, 0, -65556, 2, 0, -65555, 2, 0, -65554, 2, 0, -65553, 2, 0, -65552, 2, 0, -65551, 2, 0, -65550, 2, 0, -65549, 2, 0, -65548, 2, 0, -65547, 2, 0, -65546, 2, 0, -65545, 2, 0, -65544, 2, 0, -65543, 2, 0, -65542, 2, 0, -65541, 2, 0, -65540, 2, 0, -65539, 2, 0, -65538, 2, 0, -65537, 2, 0, -131064, 2, 0, -131063, 2, 0, -131062, 3, 0, -131061, 3, 0, -131060, 2, 0, -131058, 2, 0, -131057, 3, 0, -131056, 3, 0, -131055, 2, 0, -131054, 2, 0, -131053, 2, 0, -131045, 3, 0, -131044, 3, 0, -30, 2, 0, -22, 2, 0, -65517, 3, 0, -65508, 3, 0, 65506, 2, 0, 28, 3, 0, 131042, 2, 0, 131050, 2, 0, 65555, 3, 0, 65564, 3, 0, 196578, 2, 0, 196586, 2, 0, 196587, 2, 0, 196588, 2, 0, 196589, 3, 0, 196590, 2, 0, 196591, 2, 0, 196592, 3, 0, 196593, 3, 0, 196595, 3, 0, 196596, 3, 0, 196597, 2, 0, 196598, 3, 0, 196599, 3, 0, 196600, 2, 0, 196602, 3, 0, 196603, 2, 0, 196604, 2, 0, 196605, 2, 0, 196606, 3, 0, 196607, 3, 0, 131072, 2, 0, 131080, 2, 0, 131081, 3, 0, 131082, 3, 0, 131084, 3, 0, 131086, 3, 0, 131087, 2, 0, 131088, 2, 0, 131089, 2, 0, 131090, 2, 0, 131091, 2, 0, 131099, 3, 0, 131100, 3, 0, 262114, 2, 0, 262122, 2, 0, 262123, 2, 0, 262127, 2, 0, 262133, 3, 0, 262141, 2, 0, 196608, 2, 0, 196609, 2, 0, 196616, 3, 0, 196627, 2, 0, 196632, 3, 0, 196633, 3, 0, 196634, 3, 0, 196635, 3, 0, 327650, 2, 0, 327651, 2, 0, 327652, 2, 0, 327653, 2, 0, 327659, 2, 0, 327663, 2, 0, 327677, 2, 0, 262145, 2, 0, 262163, 2, 0, 262164, 2, 0, 262165, 3, 0, 262166, 2, 0, 262167, 2, 0, 262168, 3, 0, 393189, 2, 0, 393195, 2, 0, 393199, 3, 0, 393205, 2, 0, 393213, 2, 0, 327681, 2, 0, 327699, 3, 0, 458725, 2, 0, 458731, 2, 0, 458735, 3, 0, 458741, 3, 0, 393217, 2, 0, 393224, 3, 0, 393235, 3, 0, 524261, 2, 0, 524262, 3, 0, 524263, 3, 0, 524264, 2, 0, 524265, 2, 0, 524266, 2, 0, 524267, 2, 0, 524277, 3, 0, 524285, 2, 0, 458753, 3, 0, 458760, 2, 0, 458761, 2, 0, 458762, 3, 0, 458763, 3, 0, 458764, 2, 0, 458765, 2, 0, 458766, 3, 0, 458767, 3, 0, 458768, 3, 0, 458769, 2, 0, 458770, 2, 0, 458771, 2, 0, 589803, 3, 0, 589807, 2, 0, 589813, 2, 0, 589821, 2, 0, 524289, 3, 0, 524296, 2, 0, 655339, 2, 0, 655340, 2, 0, 655341, 3, 0, 655342, 3, 0, 655343, 2, 0, 655344, 3, 0, 655345, 3, 0, 655346, 2, 0, 655347, 3, 0, 655348, 3, 0, 655349, 2, 0, 655350, 2, 0, 655351, 3, 0, 655352, 3, 0, 655353, 3, 0, 655354, 3, 0, 655355, 3, 0, 655356, 2, 0, 655357, 2, 0, 655358, 2, 0, 655359, 2, 0, 589824, 2, 0, 589825, 2, 0, 589826, 3, 0, 589827, 3, 0, 589828, 3, 0, 589829, 3, 0, 589830, 3, 0, 589831, 3, 0, 589832, 2, 0 )
|
||||
script = ExtResource( 3 )
|
||||
extended_tilemap_node = NodePath("../1x1")
|
||||
|
||||
[node name="1x1" type="TileMap" parent="tiles"]
|
||||
z_index = 5
|
||||
z_as_relative = false
|
||||
tile_set = ExtResource( 2 )
|
||||
cell_size = Vector2( 16, 16 )
|
||||
format = 1
|
||||
|
||||
[node name="engines" type="Node2D" parent="."]
|
||||
modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
|
||||
|
|
|
@ -2,20 +2,20 @@ extends Control
|
|||
|
||||
const REFRESH_SERVER_DELAY = 5.0
|
||||
|
||||
export var scale = 4 setget set_scale
|
||||
export var upThreshold = 1.0/59.0
|
||||
export var downThreshold = 1.0/30.0
|
||||
export var scale := 4.0 setget set_scale
|
||||
export var upThreshold := 1.0/59.0
|
||||
export var downThreshold := 1.0/30.0
|
||||
|
||||
export var delay = 1.0
|
||||
export var refresh_server_remaining = REFRESH_SERVER_DELAY
|
||||
export var delay := 1.0
|
||||
export var refresh_server_remaining := REFRESH_SERVER_DELAY
|
||||
|
||||
onready var viewport = $Viewport
|
||||
onready var background = $Background
|
||||
onready var netgame = $"/root/Multiplayer"
|
||||
onready var server_list = $Popup/MarginContainer/VBoxContainer/ItemList
|
||||
onready var name_field = $CenterContainer/PanelContainer/HBoxContainer/HBoxContainer/NameField
|
||||
onready var viewport := $Viewport
|
||||
onready var background := $Background
|
||||
onready var netgame := $"/root/Multiplayer"
|
||||
onready var server_list := $Popup/MarginContainer/VBoxContainer/ItemList
|
||||
onready var name_field := $CenterContainer/PanelContainer/HBoxContainer/HBoxContainer/NameField
|
||||
|
||||
var servers = []
|
||||
var servers := []
|
||||
|
||||
func _ready() -> void:
|
||||
name_field.text = netgame.player_name
|
||||
|
|
44
Scenes/UI.gd
44
Scenes/UI.gd
|
@ -11,36 +11,36 @@ enum PopupName {
|
|||
EnergyUsage
|
||||
}
|
||||
|
||||
onready var logs = $Logs
|
||||
onready var inspect_box = $InspectBox as RichTextLabel
|
||||
onready var item_slots_container = $ItemSlots
|
||||
onready var logs := $Logs
|
||||
onready var inspect_box := $InspectBox as RichTextLabel
|
||||
onready var item_slots_container := $ItemSlots
|
||||
|
||||
onready var map_popup = $MapPopup
|
||||
onready var sever_info_popup = $ServerInfoPopup
|
||||
onready var map_popup := $MapPopup
|
||||
onready var sever_info_popup := $ServerInfoPopup
|
||||
|
||||
onready var scene = $"/root/scene"
|
||||
onready var netgame = $"/root/Multiplayer"
|
||||
onready var scene := $"/root/scene"
|
||||
onready var netgame := $"/root/Multiplayer"
|
||||
|
||||
const ItemBox = preload("res://Scenes/UI/Items/ItemBox.tscn")
|
||||
var left_selected = null
|
||||
var right_selected = null
|
||||
const ItemBox := preload("res://Scenes/UI/Items/ItemBox.tscn")
|
||||
var left_selected: Node = null
|
||||
var right_selected: Node = null
|
||||
|
||||
const WHISPER_RADIUS = 32*3
|
||||
const CHAT_RADIUS = 32*10
|
||||
const SHOUT_RADIUS = 32*14
|
||||
const WHISPER_RADIUS := 32*3
|
||||
const CHAT_RADIUS := 32*10
|
||||
const SHOUT_RADIUS := 32*14
|
||||
|
||||
var inspect_mode = false
|
||||
var inspect_mode := false
|
||||
var current_inspecting = null
|
||||
|
||||
func _ready() -> void:
|
||||
# Add options to menu buttons
|
||||
var serverMenu = $Menu/Margins/Grid/Server.get_popup()
|
||||
var serverMenu := ($Menu/Margins/Grid/Server as MenuButton).get_popup()
|
||||
serverMenu.connect("id_pressed", self, "_server_option_chosen")
|
||||
serverMenu.add_item("Server info", ServerMenuItem.ServerInfo)
|
||||
|
||||
# Create item slots
|
||||
for slot_id in range(4):
|
||||
var item_slot = ItemBox.instance()
|
||||
var item_slot := ItemBox.instance()
|
||||
|
||||
# By default, slot 2/3 are L/R, and 2 is selected
|
||||
match slot_id:
|
||||
|
@ -60,7 +60,7 @@ func _ready() -> void:
|
|||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if inspect_mode:
|
||||
var mouse_pos = scene.world.get_local_mouse_position() * scene.world.scale
|
||||
var mouse_pos: Vector2 = scene.world.get_local_mouse_position() * scene.world.scale
|
||||
var results = scene.physics.intersect_point(mouse_pos, 1, [], 2)
|
||||
if results.size() > 0:
|
||||
var obj = results[0].collider
|
||||
|
@ -136,7 +136,7 @@ func _input(event: InputEvent) -> void:
|
|||
elif event.is_action_pressed("swap_hands"):
|
||||
swap_hands()
|
||||
elif event is InputEventMouseMotion:
|
||||
var mousemotion = event as InputEventMouseMotion
|
||||
var mousemotion := event as InputEventMouseMotion
|
||||
if inspect_mode:
|
||||
inspect_box.rect_global_position = mousemotion.position + inspect_offset
|
||||
|
||||
|
@ -172,12 +172,12 @@ func check_popups() -> bool:
|
|||
return map_popup.visible or sever_info_popup.visible
|
||||
|
||||
func select_next_box(direction: int, right_hand: bool) -> void:
|
||||
var box = left_selected as UIItemBox
|
||||
var box := left_selected as UIItemBox
|
||||
if right_hand:
|
||||
box = right_selected
|
||||
var parent = box.get_parent()
|
||||
var child_count = parent.get_child_count()
|
||||
var index = box.get_index()
|
||||
var parent := box.get_parent()
|
||||
var child_count := parent.get_child_count()
|
||||
var index := box.get_index()
|
||||
index += direction
|
||||
if index < 0:
|
||||
index = child_count + index
|
||||
|
|
|
@ -11,14 +11,14 @@ enum CurrentHand {
|
|||
Right
|
||||
}
|
||||
|
||||
var hovering = false
|
||||
export var selected = false setget set_selected
|
||||
export(CurrentHand) var current_hand = CurrentHand.None setget set_hand
|
||||
var hovering := false
|
||||
export var selected := false setget set_selected
|
||||
export(CurrentHand) var current_hand := CurrentHand.None setget set_hand
|
||||
|
||||
const LEFT_Y_OFFSET = 0
|
||||
const RIGHT_Y_OFFSET = 10
|
||||
const LEFT_Y_OFFSET := 0
|
||||
const RIGHT_Y_OFFSET := 10
|
||||
|
||||
onready var hand_icon = $HandIcon
|
||||
onready var hand_icon := $HandIcon
|
||||
|
||||
func _ready():
|
||||
hand_icon.texture = hand_icon.texture.duplicate()
|
||||
|
@ -50,7 +50,7 @@ func set_hand(hand):
|
|||
|
||||
func _gui_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
var mouse_event = event as InputEventMouseButton
|
||||
var mouse_event := event as InputEventMouseButton
|
||||
if mouse_event.pressed:
|
||||
if mouse_event.button_index == BUTTON_LEFT:
|
||||
if current_hand != CurrentHand.Left:
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
extends Control
|
||||
|
||||
export var cell_size = 150
|
||||
export var bgzoom = 50
|
||||
export var cell_size := 150
|
||||
export var bgzoom := 50
|
||||
|
||||
const BORDER_WIDTH = 4
|
||||
const BORDER_LENGTH = 30
|
||||
const RADAR_EFFECT_DELAY = 1
|
||||
const HALF_BORDER = BORDER_LENGTH/2
|
||||
const BORDER_WIDTH := 4
|
||||
const BORDER_LENGTH := 30
|
||||
const RADAR_EFFECT_DELAY := 1
|
||||
const HALF_BORDER := BORDER_LENGTH/2
|
||||
|
||||
const MIN_ZOOM = 40
|
||||
const ZOOM_STEP = 10
|
||||
const MAX_ZOOM = 400
|
||||
const MIN_ZOOM := 40
|
||||
const ZOOM_STEP := 10
|
||||
const MAX_ZOOM := 400
|
||||
|
||||
export(Texture) var background
|
||||
export(Font) var font
|
||||
|
||||
var inside = false
|
||||
var dragging = false
|
||||
var origin = Vector2.ZERO
|
||||
var last_origin = origin
|
||||
var last_mouse_pos = Vector2.ZERO
|
||||
var set_position = true
|
||||
var radar_next_remaining = RADAR_EFFECT_DELAY
|
||||
var offset = Vector2.ZERO
|
||||
var text_two_lines = false
|
||||
var inside := false
|
||||
var dragging := false
|
||||
var origin := Vector2.ZERO
|
||||
var last_origin := origin
|
||||
var last_mouse_pos := Vector2.ZERO
|
||||
var set_position := true
|
||||
var radar_next_remaining := RADAR_EFFECT_DELAY
|
||||
var offset := Vector2.ZERO
|
||||
var text_two_lines := false
|
||||
|
||||
onready var scene = $"/root/scene"
|
||||
onready var speed_text = $"../HBoxContainer/HBoxContainer/CurrentSpeed"
|
||||
onready var dir_text = $"../HBoxContainer/HBoxContainer/CurrentAngle"
|
||||
onready var popup = $"../../.."
|
||||
onready var scene := $"/root/scene"
|
||||
onready var speed_text := $"../HBoxContainer/HBoxContainer/CurrentSpeed"
|
||||
onready var dir_text := $"../HBoxContainer/HBoxContainer/CurrentAngle"
|
||||
onready var popup := $"../../.."
|
||||
|
||||
var last_pos = []
|
||||
var last_pos := []
|
||||
|
||||
func _ready():
|
||||
font = font.duplicate()
|
||||
|
@ -38,7 +38,7 @@ func _ready():
|
|||
func _physics_process(delta):
|
||||
radar_next_remaining -= delta
|
||||
if radar_next_remaining < 0:
|
||||
var current_position = (scene.world.map.current_ship_position + scene.world.map.current_ship_subpos)
|
||||
var current_position: Vector2 = scene.world.map.current_ship_position + scene.world.map.current_ship_subpos
|
||||
last_pos.append(current_position)
|
||||
if last_pos.size() > 20:
|
||||
last_pos.pop_front()
|
||||
|
@ -50,17 +50,17 @@ func _physics_process(delta):
|
|||
update()
|
||||
|
||||
func _draw():
|
||||
var win_size = get_global_rect().size
|
||||
var current_position = (scene.world.map.current_ship_position + scene.world.map.current_ship_subpos) * cell_size
|
||||
var win_size := get_global_rect().size
|
||||
var current_position: Vector2 = (scene.world.map.current_ship_position + scene.world.map.current_ship_subpos) * cell_size
|
||||
if set_position:
|
||||
origin = current_position - win_size/2
|
||||
last_origin = origin
|
||||
if win_size.x > 0:
|
||||
set_position = false
|
||||
var cols = int(ceil(win_size.x/cell_size))
|
||||
var rows = int(ceil(win_size.y/cell_size))
|
||||
var xoffset = float(int(origin.x) % cell_size)
|
||||
var yoffset = float(int(origin.y) % cell_size)
|
||||
var cols := int(ceil(win_size.x/cell_size))
|
||||
var rows := int(ceil(win_size.y/cell_size))
|
||||
var xoffset := float(int(origin.x) % cell_size)
|
||||
var yoffset := float(int(origin.y) % cell_size)
|
||||
draw_texture_rect_region(background, Rect2(Vector2.ZERO, win_size), Rect2(origin*bgzoom, win_size*bgzoom), Color(0.5,0.5,0.5,1))
|
||||
for i in range(0, cols+1):
|
||||
draw_line(Vector2(i * cell_size-xoffset, 0), Vector2(i * cell_size-xoffset, win_size.y), Color.white * 0.5)
|
||||
|
@ -68,8 +68,8 @@ func _draw():
|
|||
draw_line(Vector2(0, i * cell_size-yoffset), Vector2(win_size.x, i * cell_size-yoffset), Color.white * 0.5)
|
||||
for x in range(-1, cols+1):
|
||||
for y in range(-1, rows+1):
|
||||
var real_x = x + int(origin.x/cell_size)
|
||||
var real_y = y + int(origin.y/cell_size)
|
||||
var real_x := x + int(origin.x/cell_size)
|
||||
var real_y := y + int(origin.y/cell_size)
|
||||
var sector = Coordinates.as_string_parts(Vector2(real_x, real_y))
|
||||
if text_two_lines:
|
||||
draw_string(font, Vector2(x * cell_size + 6 - xoffset, y * cell_size + 20 - yoffset), sector[0], Color(1,1,1,0.5))
|
||||
|
@ -77,9 +77,9 @@ func _draw():
|
|||
else:
|
||||
draw_string(font, Vector2(x * cell_size + 6 - xoffset, y * cell_size + 20 - yoffset), sector[0] + sector[1], Color(1,1,1,0.5))
|
||||
|
||||
var viewport = Rect2(origin, win_size)
|
||||
var viewport := Rect2(origin, win_size)
|
||||
|
||||
var point_count = last_pos.size()
|
||||
var point_count := last_pos.size()
|
||||
for pos_index in range(0, point_count):
|
||||
draw_circle(last_pos[pos_index] * cell_size - origin, 2, Color(1, 0, 0, pos_index*1.0/point_count))
|
||||
|
||||
|
@ -90,7 +90,7 @@ func _draw():
|
|||
|
||||
var current_target = scene.world.map.current_ship_target
|
||||
if current_target != null:
|
||||
var current_target_adj = current_target * cell_size
|
||||
var current_target_adj := (current_target as Vector2) * cell_size
|
||||
draw_target(viewport, current_target_adj, Color.green)
|
||||
draw_line(current_position - origin, current_target_adj - origin, Color.darkcyan)
|
||||
|
||||
|
@ -100,8 +100,8 @@ func draw_target(viewport: Rect2, position: Vector2, color: Color):
|
|||
draw_circle(position - viewport.position, 5, color)
|
||||
else:
|
||||
# Draw line pointing to target
|
||||
var relative_pos = position - viewport.position
|
||||
var clamped = Vector2(clamp(relative_pos.x, 0, viewport.size.x), clamp(relative_pos.y, 0, viewport.size.y))
|
||||
var relative_pos := position - viewport.position
|
||||
var clamped := Vector2(clamp(relative_pos.x, 0, viewport.size.x), clamp(relative_pos.y, 0, viewport.size.y))
|
||||
if relative_pos.x < 0:
|
||||
draw_line(Vector2(0, clamped.y-HALF_BORDER), Vector2(0, clamped.y+HALF_BORDER), color, BORDER_WIDTH)
|
||||
elif relative_pos.x > viewport.size.x:
|
||||
|
@ -148,7 +148,7 @@ func update_font():
|
|||
font.size = 14
|
||||
|
||||
func _recalc_offset(mult: float):
|
||||
var mouse = get_local_mouse_position()
|
||||
var mouse := get_local_mouse_position()
|
||||
origin = ((origin + mouse) / cell_size * (cell_size + mult)) - mouse
|
||||
|
||||
func _reset_position():
|
||||
|
|
|
@ -4,9 +4,9 @@ class_name GameWorld
|
|||
|
||||
enum Map { RUNTIME, ODYSSEY, EMPTY }
|
||||
|
||||
const playerRes = preload("res://Actors/Player/Player.tscn")
|
||||
const playerRes := preload("res://Actors/Player/Player.tscn")
|
||||
|
||||
var map = null
|
||||
var map: GameMap = null
|
||||
var player = null
|
||||
|
||||
onready var scene_manager = $"/root/SceneManager"
|
||||
|
@ -22,10 +22,10 @@ func load_map(map_name):
|
|||
add_child(map)
|
||||
|
||||
func spawn_player(peer: int, is_current_user: bool):
|
||||
var playerNode = playerRes.instance()
|
||||
var playerNode := playerRes.instance()
|
||||
playerNode.set_network_master(peer, true)
|
||||
playerNode.is_controlled = is_current_user
|
||||
var spawnpoints = map.get_pois(POI.POIType.SpawnPoint, POI.POIClass.Player)
|
||||
var spawnpoints := map.get_pois(POI.POIType.SpawnPoint, POI.POIClass.Player)
|
||||
if spawnpoints.size() > 0:
|
||||
playerNode.transform.origin = (spawnpoints[0] as Node2D).transform.origin
|
||||
else:
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
extends Node
|
||||
|
||||
class_name GameSystems
|
||||
|
||||
func serialize() -> Dictionary:
|
||||
var systems = {}
|
||||
var systems := {}
|
||||
for child in get_children():
|
||||
systems[child.name] = {
|
||||
"script": child.script.resource_path,
|
||||
|
@ -11,7 +13,7 @@ func serialize() -> Dictionary:
|
|||
|
||||
func deserialize(data: Dictionary) -> void:
|
||||
for system_name in data:
|
||||
var system_data = data[system_name] as Dictionary
|
||||
var system_data := data[system_name] as Dictionary
|
||||
var system_node = load(system_data.script).new()
|
||||
system_node.name = system_name
|
||||
add_child(system_node, true)
|
||||
|
|
|
@ -64,6 +64,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://Actors/Objects/Scanner/Scanner.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "GameSystems",
|
||||
"language": "GDScript",
|
||||
"path": "res://Scenes/systems.gd"
|
||||
}, {
|
||||
"base": "Control",
|
||||
"class": "GameUI",
|
||||
"language": "GDScript",
|
||||
|
@ -119,6 +124,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://Classes/ResourceQueue.gd"
|
||||
}, {
|
||||
"base": "ScrollContainer",
|
||||
"class": "TileTab",
|
||||
"language": "GDScript",
|
||||
"path": "res://Scenes/Editor/TileTab.gd"
|
||||
}, {
|
||||
"base": "Reference",
|
||||
"class": "UICommand",
|
||||
"language": "GDScript",
|
||||
|
@ -141,6 +151,7 @@ _global_script_class_icons={
|
|||
"GameObjectLightbulb": "",
|
||||
"GameObjectPowerStorage": "",
|
||||
"GameObjectScanner": "",
|
||||
"GameSystems": "",
|
||||
"GameUI": "",
|
||||
"GameWorld": "",
|
||||
"MapTiles": "",
|
||||
|
@ -152,6 +163,7 @@ _global_script_class_icons={
|
|||
"ProbeArea": "",
|
||||
"ProbeElectric": "",
|
||||
"ResourceQueue": "",
|
||||
"TileTab": "",
|
||||
"UICommand": "",
|
||||
"UIItemBox": ""
|
||||
}
|
||||
|
|
Reference in a new issue