Compare commits

...
This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.

13 commits

Author SHA1 Message Date
d5d450d7f6
More refactoring! 2020-09-24 12:59:40 +02:00
99d59507e6
Make obj box bigger 2020-09-24 12:57:00 +02:00
6df316e338
Add some object entries 2020-09-24 12:56:53 +02:00
b403ea7246
Refactor a lot of duplicated code 2020-09-24 12:56:33 +02:00
da43ba87e2
Add fill, start work on adding items 2020-09-22 10:06:17 +02:00
0fa89de972
More work on map editor 2020-09-18 01:47:16 +02:00
18090a86aa
Map editor goes brrr 2020-09-16 01:24:15 +02:00
780b743d8b
GOOD BYE 1x1 2020-09-16 01:24:08 +02:00
622ea1640d
GDscript typeees 2020-09-16 01:23:45 +02:00
e977769912
Stub work for bodyparts 2020-09-11 11:30:35 +02:00
1fbd1149ee
Add new space, remove obsolete runtime-map 2020-09-11 11:30:14 +02:00
1ee091c395
Misc fixes to space map 2020-09-11 11:29:45 +02:00
91b29162aa
Start work on map editor 2020-09-11 11:29:06 +02:00
52 changed files with 1803 additions and 745 deletions

View file

@ -7,15 +7,25 @@ class_name GameObjectComputer
enum Direction { LEFT, RIGHT, UP, DOWN } enum Direction { LEFT, RIGHT, UP, DOWN }
enum ComputerType { ShipCommand, Comms, Medical, Research, Energy, ShipEngine, Atmos, Monitoring } enum ComputerType { ShipCommand, Comms, Medical, Research, Energy, ShipEngine, Atmos, Monitoring }
export var object_name = "" export var object_name := ""
export(Direction) var direction = Direction.DOWN setget set_direction export(Direction) var direction := Direction.DOWN setget set_direction
export(ComputerType) var computer_type = ComputerType.ShipCommand setget set_type export(ComputerType) var computer_type := ComputerType.ShipCommand setget set_type
var screen_region_offset = Vector2.ZERO var screen_region_offset := Vector2.ZERO
var open = false var open := false
onready var activationRange = $ActivationRange as ActivationRange onready var activationRange := $ActivationRange as ActivationRange
onready var manager = $PowerManager as PowerManager onready var manager := $PowerManager as PowerManager
static func editor_info():
var editor_icon = AtlasTexture.new()
editor_icon.atlas = preload("res://Graphics/tgstation/computer.png")
editor_icon.region = Rect2(0, 0, 32, 32)
return {
"name": "Computer",
"scene": load("res://Actors/Objects/Computer/Computer.tscn"),
"icon": editor_icon
}
func _ready(): func _ready():
if not Engine.editor_hint: if not Engine.editor_hint:

View file

@ -2,21 +2,31 @@ extends StaticBody2D
class_name GameObjectDoor class_name GameObjectDoor
export var object_name = "" export var object_name := ""
export(NodePath) var interlockTargetPath export(NodePath) var interlockTargetPath
var interlockTarget: GameObjectDoor = null var interlockTarget: GameObjectDoor = null
var open_sound = preload("res://Sounds/SFX/effects/door-open.wav") var open_sound := preload("res://Sounds/SFX/effects/door-open.wav")
var close_sound = preload("res://Sounds/SFX/effects/door-close.wav") var close_sound := preload("res://Sounds/SFX/effects/door-close.wav")
export var idle_usage = 2 export var idle_usage := 2
export var active_usage = 10 export var active_usage := 10
onready var activationRange = $ActivationRange as ActivationRange onready var activationRange := $ActivationRange as ActivationRange
onready var manager = $PowerManager as PowerManager onready var manager := $PowerManager as PowerManager
signal changed(open) signal changed(open)
static func editor_info():
var editor_icon = AtlasTexture.new()
editor_icon.atlas = preload("res://Graphics/tgstation/opening-sheet.png")
editor_icon.region = Rect2(0, 0, 32, 32)
return {
"name": "Door",
"scene": load("res://Actors/Objects/Door/Door.tscn"),
"icon": editor_icon
}
func _ready(): func _ready():
if is_network_master(): if is_network_master():
if interlockTargetPath != null: if interlockTargetPath != null:

View file

@ -7,10 +7,10 @@ class_name ElectricSocket
enum Direction { LEFT, RIGHT, UP, DOWN } enum Direction { LEFT, RIGHT, UP, DOWN }
enum Flow { SOURCE, SINK, BIDIRECTIONAL } 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 = [] export(Array, NodePath) var connectionPaths := []
var connections = [] var connections := []
export(Color) var source_color export(Color) var source_color
export(Color) var sink_color export(Color) var sink_color
@ -31,7 +31,7 @@ func _ready() -> void:
add_connection(get_node(connection)) add_connection(get_node(connection))
func add_connection(node: Node) -> void: 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 manager.socket = self
connections.append(manager) connections.append(manager)
@ -64,7 +64,7 @@ func refresh_sprite() -> void:
socket.material.set_shader_param("cable_color", bidirectional_color) socket.material.set_shader_param("cable_color", bidirectional_color)
func serialize(): func serialize():
var connection_paths = [] var connection_paths := []
for conn in connections: for conn in connections:
connection_paths.append({ "path": get_path_to(conn), "powered": conn.powered }) connection_paths.append({ "path": get_path_to(conn), "powered": conn.powered })
@ -78,7 +78,7 @@ func deserialize(data):
set_direction(data["direction"]) set_direction(data["direction"])
set_flow(data["flow"]) set_flow(data["flow"])
for node in data["connections"]: 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.socket = self
manager.powered = node.powered manager.powered = node.powered
connections.append(manager) connections.append(manager)

View file

@ -21,6 +21,16 @@ export var max_force = 0.05
var force = 0 var force = 0
static func editor_info():
var editor_icon = AtlasTexture.new()
editor_icon.atlas = preload("res://Graphics/tgstation/engine-big.png")
editor_icon.region = Rect2(0, 0, 96, 96)
return {
"name": "Engine",
"scene": load("res://Actors/Objects/Engine/Engine.tscn"),
"icon": editor_icon
}
func _ready() -> void: func _ready() -> void:
if not Engine.editor_hint: if not Engine.editor_hint:
activationRange.visible = true activationRange.visible = true

View file

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[sub_resource type="CircleShape2D" id=1]
[node name="Node2D" type="Area2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )

View file

@ -12,6 +12,16 @@ export var lit = true setget set_lit
onready var activationRange = $ActivationRange as ActivationRange onready var activationRange = $ActivationRange as ActivationRange
onready var manager = $PowerManager as PowerManager onready var manager = $PowerManager as PowerManager
static func editor_info():
var editor_icon = AtlasTexture.new()
editor_icon.atlas = preload("res://Graphics/tgstation/light.png")
editor_icon.region = Rect2(32, 0, 32, 32)
return {
"name": "Light fixture",
"scene": load("res://Actors/Objects/Lightbulb/Lightbulb.tscn"),
"icon": editor_icon
}
func _ready(): func _ready():
if not Engine.editor_hint: if not Engine.editor_hint:
activationRange.visible = true activationRange.visible = true

View file

@ -15,6 +15,13 @@ export var max_discharge_rate = 2000 setget set_max_discharge
var next_network_update = Multiplayer.SYSTEMS_UPDATE_INTERVAL var next_network_update = Multiplayer.SYSTEMS_UPDATE_INTERVAL
static func editor_info():
return {
"name": "BFB",
"scene": load("res://Actors/Objects/PowerStorage/PowerStorage.tscn"),
"icon": preload("res://Graphics/tgstation/smes.png")
}
func _ready() -> void: func _ready() -> void:
if not Engine.editor_hint: if not Engine.editor_hint:
activationRange.visible = true activationRange.visible = true

View file

@ -1,5 +1,8 @@
extends Node2D extends Node2D
const MAX_HEALTH = 100.0 var base_hp := 100.0
var health = MAX_HEALTH var damage := 0.0
func get_health() -> float:
return base_hp - damage

View file

@ -1,34 +1,36 @@
extends KinematicBody2D extends KinematicBody2D
const BASE_SPEED = 300.0 const BASE_SPEED := 300.0
const EPSILON = 0.1 const EPSILON := 0.1
const MAX_STAMINA = 3.0 const MAX_STAMINA := 3.0
const BOOST_COEFF = 50.0 const BOOST_COEFF := 50.0
const STAMINA_RECOVER_RATE = 0.3 const STAMINA_RECOVER_RATE := 0.3
const NET_KEY_TRANSFORM_DELAY = 0.2 const NET_KEY_TRANSFORM_DELAY := 0.2
var velocity = Vector2.ZERO var velocity := Vector2.ZERO
var grip = 1.0 var grip := 1.0
var stamina = MAX_STAMINA var stamina := MAX_STAMINA
var speed_boost = 0 var speed_boost := 0
var transform_update_remaining = 0.0 var transform_update_remaining := 0.0
puppet var pup_motion = Vector2.ZERO puppet var pup_motion := Vector2.ZERO
puppet var pup_velocity = Vector2.ZERO puppet var pup_velocity := Vector2.ZERO
puppet var pup_transform = Transform() puppet var pup_transform := Transform()
onready var scene = $"/root/scene" onready var scene := $"/root/scene"
onready var world = $"/root/scene/world" onready var world := $"/root/scene/world"
onready var camera = $Camera onready var camera := $Camera
onready var netgame = $"/root/Multiplayer" 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
func _ready(): func _ready():
$Camera.current = is_controlled $Camera.current = is_controlled
func _physics_process(delta): func _physics_process(delta):
var motion = Vector2.ZERO var motion := Vector2.ZERO
if is_network_master(): if is_network_master():
if not scene.writing: if not scene.writing:
motion = Vector2( motion = Vector2(
@ -36,7 +38,7 @@ func _physics_process(delta):
Input.get_action_strength("ui_down")-Input.get_action_strength("ui_up")) Input.get_action_strength("ui_down")-Input.get_action_strength("ui_up"))
# Check sprinting # Check sprinting
var speed = BASE_SPEED var speed := BASE_SPEED
if Input.is_action_pressed("sprint") and not scene.writing: if Input.is_action_pressed("sprint") and not scene.writing:
if motion.length() > EPSILON and stamina > 0: if motion.length() > EPSILON and stamina > 0:
speed_boost += BOOST_COEFF * delta * ease(stamina/MAX_STAMINA, 1.1) speed_boost += BOOST_COEFF * delta * ease(stamina/MAX_STAMINA, 1.1)
@ -91,10 +93,10 @@ func _draw():
draw_circle_arc_poly(Vector2(-10, -30), 6, 0, stamina/MAX_STAMINA * 360, Color.orange) 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): func draw_circle_arc_poly(center, radius, angle_from, angle_to, color):
var nb_points = 32 var nb_points := 32
var points_arc = PoolVector2Array() var points_arc := PoolVector2Array()
points_arc.push_back(center) points_arc.push_back(center)
var colors = PoolColorArray([color]) var colors := PoolColorArray([color])
for i in range(nb_points + 1): for i in range(nb_points + 1):
var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90) var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90)
@ -103,3 +105,18 @@ func draw_circle_arc_poly(center, radius, angle_from, angle_to, color):
func get_info(): func get_info():
return netgame.player_info[get_network_master()] return netgame.player_info[get_network_master()]
func get_name():
var id := get_network_master()
return netgame.player_info[id].name
func inspect():
if is_network_master():
return {
"type": "Crewmember",
"description": "That's you!"
}
return {
"type": "Crewmember",
"description": "A fellow crewmember"
}

View file

@ -13,7 +13,7 @@ extents = Vector2( 32, 32 )
[node name="Player" type="KinematicBody2D"] [node name="Player" type="KinematicBody2D"]
z_index = 10 z_index = 10
collision_layer = 8 collision_layer = 10
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Camera" type="Camera2D" parent="."] [node name="Camera" type="Camera2D" parent="."]

View file

@ -1,19 +1,19 @@
class_name Coordinates class_name Coordinates
static func as_string(coord: Vector2, include_subcoord: bool = false) -> String: static func as_string(coord: Vector2, include_subcoord: bool = false) -> String:
var x = floor(coord.x) var x := floor(coord.x)
var y = floor(coord.y) var y := floor(coord.y)
var main = as_string_parts(coord) var main := as_string_parts(coord)
var sector_name = main[0] + main[1] var sector_name := str(main[0]) + str(main[1])
if include_subcoord: if include_subcoord:
sector_name += ".%02d/%02d" % [(coord.x - x) * 100, (coord.y - y) * 100] sector_name += ".%02d/%02d" % [(coord.x - x) * 100, (coord.y - y) * 100]
return sector_name return sector_name
static func as_string_parts(coord: Vector2) -> Array: static func as_string_parts(coord: Vector2) -> Array:
var x = floor(coord.x) var x := floor(coord.x)
var y = floor(coord.y) var y := floor(coord.y)
var x_str = to_letter(int(x)) var x_str := to_letter(int(x))
var y_str = "" var y_str := ""
if y < 0: if y < 0:
y_str = to_letter(int(y)) y_str = to_letter(int(y))
else: else:
@ -23,15 +23,15 @@ static func as_string_parts(coord: Vector2) -> Array:
static func to_letter(num: int) -> String: static func to_letter(num: int) -> String:
#var letters = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ" #var letters = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" var letters := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if num == 0: if num == 0:
return "Α" return "Α"
elif num < 0: elif num < 0:
letters = "αβγδεζηθικλμνξοπρστυφχψω" letters = "αβγδεζηθικλμνξοπρστυφχψω"
if num < 0: if num < 0:
num = -num num = -num
var out = "" var out := ""
var base = letters.length() var base := letters.length()
while num > 0: while num > 0:
out = letters.substr(num % base, 1) + out out = letters.substr(num % base, 1) + out
num /= base num /= base

View file

@ -0,0 +1,46 @@
shader_type canvas_item;
uniform sampler2D noise_sparse;
uniform sampler2D noise_fine;
uniform float scroll_speed = 0.0;
uniform float warp_boost: hint_range(1, 10) = 1.0;
uniform float warp_opacity : hint_range(0, 1) = 0.0;
const float noise_sparse_scale = 0.0007;
const float noise_fine_scale = 0.003;
const float warp_clouds_scale = 0.0003;
const vec2 scroll_dir = vec2(1,0);
const vec2 blink_scroll = vec2(50.0, 0);
const float PI = 3.1415;
render_mode unshaded;
void fragment() {
float scroll = scroll_speed * TIME;
float sparse = texture(noise_sparse, (FRAGCOORD.xy + scroll_dir * scroll)*noise_sparse_scale).r;
sparse = ((sparse * sparse) - 0.2) * 1.2;
float fine = texture(noise_fine, (FRAGCOORD.xy + scroll_dir * scroll)*noise_fine_scale).r;
fine = fine - 0.6;
if (fine > 0.) {
fine = fine * 10.0;
}
if (fine > 0.3) {
float fine_blink_fade = texture(noise_sparse, (FRAGCOORD.xy + blink_scroll*TIME)*noise_sparse_scale).r;
fine = fine - ((fine_blink_fade * fine_blink_fade) - 0.2) * 1.2;
}
vec4 clouds = vec4(vec3(0.3, 0.5, 0.7) * sparse, 1.0);
vec4 stars = vec4(fine);
vec2 warp_scroll = scroll_dir * scroll;
vec2 warp_uv = (FRAGCOORD.xy * sin(SCREEN_UV.y * PI) + warp_scroll)*warp_clouds_scale;
vec2 warp_uv_inv = (FRAGCOORD.xy * sin((abs(SCREEN_UV.y-0.5)) * SCREEN_UV.x * PI) + warp_scroll*0.5)*warp_clouds_scale;
float warp_clouds_sparse = texture(noise_sparse, vec2(0.5,1) * warp_uv).r;
float warp_clouds_fine = texture(noise_sparse, vec2(2,1) * warp_uv_inv).r;
vec4 warp = vec4(vec3(0), 1);
warp += vec4(vec3(0.3,0.2,0.9)*warp_clouds_sparse, 0);
warp += vec4(vec3(0.5,0.0,0.5)*(warp_clouds_fine*0.5+warp_clouds_sparse)*abs(SCREEN_UV.y-0.5), 0);
COLOR = mix(clouds + stars, warp*warp_boost, warp_opacity);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/editor-icons.png-19e09808b25bd1fc0ab5c47cf04a47fd.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/UI/editor-icons.png"
dest_files=[ "res://.import/editor-icons.png-19e09808b25bd1fc0ab5c47cf04a47fd.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
Graphics/UI/grid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/grid.png-dcf3a2dc07c07f64832e0ff565fb3712.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/UI/grid.png"
dest_files=[ "res://.import/grid.png-dcf3a2dc07c07f64832e0ff565fb3712.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=1
flags/filter=false
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -1,4 +1,4 @@
[gd_resource type="Theme" load_steps=4 format=2] [gd_resource type="Theme" load_steps=6 format=2]
[ext_resource path="res://Graphics/UI/uifont.tres" type="DynamicFont" id=1] [ext_resource path="res://Graphics/UI/uifont.tres" type="DynamicFont" id=1]
@ -36,8 +36,53 @@ expand_margin_right = 8.0
expand_margin_top = 8.0 expand_margin_top = 8.0
expand_margin_bottom = 8.0 expand_margin_bottom = 8.0
[sub_resource type="StyleBoxFlat" id=3]
content_margin_left = 10.0
content_margin_right = 10.0
content_margin_top = 5.0
content_margin_bottom = 0.0
bg_color = Color( 0.09962, 0.0918, 0.17, 1 )
border_width_left = 4
border_width_top = 4
border_width_right = 4
border_width_bottom = 4
border_color = Color( 0.0941176, 0.0823529, 0.180392, 1 )
border_blend = true
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
expand_margin_bottom = 2.0
[sub_resource type="StyleBoxFlat" id=4]
content_margin_left = 10.0
content_margin_right = 10.0
content_margin_top = 5.0
bg_color = Color( 0.133333, 0.12549, 0.203922, 1 )
border_width_left = 4
border_width_top = 4
border_width_right = 4
border_color = Color( 0.0941176, 0.0823529, 0.180392, 1 )
border_blend = true
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2
expand_margin_bottom = 4.0
[resource] [resource]
default_font = ExtResource( 1 ) default_font = ExtResource( 1 )
Button/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
Button/colors/font_color_hover = Color( 0.94, 0.94, 0.94, 1 )
Button/colors/font_color_pressed = Color( 1, 1, 1, 1 )
Button/constants/hseparation = 2
Button/fonts/font = null
Button/styles/disabled = null
Button/styles/focus = null
Button/styles/hover = null
Button/styles/normal = null
Button/styles/pressed = null
Panel/styles/panel = SubResource( 1 ) Panel/styles/panel = SubResource( 1 )
PanelContainer/styles/panel = SubResource( 1 ) PanelContainer/styles/panel = SubResource( 1 )
PopupDialog/styles/panel = SubResource( 1 ) PopupDialog/styles/panel = SubResource( 1 )
@ -59,3 +104,52 @@ PopupMenu/styles/labeled_separator_right = null
PopupMenu/styles/panel = SubResource( 2 ) PopupMenu/styles/panel = SubResource( 2 )
PopupMenu/styles/panel_disabled = null PopupMenu/styles/panel_disabled = null
PopupMenu/styles/separator = null PopupMenu/styles/separator = null
TabContainer/colors/font_color_bg = Color( 0.69, 0.69, 0.69, 1 )
TabContainer/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
TabContainer/colors/font_color_fg = Color( 0.94, 0.94, 0.94, 1 )
TabContainer/constants/hseparation = 4
TabContainer/constants/label_valign_bg = 2
TabContainer/constants/label_valign_fg = 0
TabContainer/constants/side_margin = 8
TabContainer/constants/top_margin = 24
TabContainer/fonts/font = null
TabContainer/icons/decrement = null
TabContainer/icons/decrement_highlight = null
TabContainer/icons/increment = null
TabContainer/icons/increment_highlight = null
TabContainer/icons/menu = null
TabContainer/icons/menu_highlight = null
TabContainer/styles/panel = SubResource( 1 )
TabContainer/styles/tab_bg = SubResource( 3 )
TabContainer/styles/tab_disabled = SubResource( 3 )
TabContainer/styles/tab_fg = SubResource( 4 )
Tabs/colors/font_color_bg = Color( 0.69, 0.69, 0.69, 1 )
Tabs/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
Tabs/colors/font_color_fg = Color( 0.94, 0.94, 0.94, 1 )
Tabs/constants/hseparation = 4
Tabs/constants/label_valign_bg = 2
Tabs/constants/label_valign_fg = 0
Tabs/constants/top_margin = 24
Tabs/fonts/font = null
Tabs/icons/close = null
Tabs/icons/decrement = null
Tabs/icons/decrement_highlight = null
Tabs/icons/increment = null
Tabs/icons/increment_highlight = null
Tabs/styles/button = null
Tabs/styles/button_pressed = null
Tabs/styles/panel = SubResource( 1 )
Tabs/styles/tab_bg = null
Tabs/styles/tab_disabled = null
Tabs/styles/tab_fg = SubResource( 1 )
ToolButton/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
ToolButton/colors/font_color_disabled = Color( 0.9, 0.95, 1, 0.3 )
ToolButton/colors/font_color_hover = Color( 0.94, 0.94, 0.94, 1 )
ToolButton/colors/font_color_pressed = Color( 1, 1, 1, 1 )
ToolButton/constants/hseparation = 3
ToolButton/fonts/font = null
ToolButton/styles/disabled = null
ToolButton/styles/focus = null
ToolButton/styles/hover = null
ToolButton/styles/normal = null
ToolButton/styles/pressed = null

View file

@ -0,0 +1,56 @@
[gd_resource type="ShaderMaterial" load_steps=6 format=2]
[sub_resource type="Shader" id=1]
code = "shader_type canvas_item;
uniform sampler2D noise_sparse;
uniform sampler2D noise_fine;
const float noise_sparse_scale = 0.0007;
const float noise_fine_scale = 0.003;
const float warp_clouds_scale = 0.0003;
const vec2 scroll_dir = vec2(1,0);
const vec2 blink_scroll = vec2(50.0, 0);
const float PI = 3.1415;
render_mode unshaded;
void fragment() {
float sparse = texture(noise_sparse, FRAGCOORD.xy*noise_sparse_scale).r;
sparse = ((sparse * sparse) - 0.2) * 1.2;
float fine = texture(noise_fine, FRAGCOORD.xy*noise_fine_scale).r;
fine = fine - 0.6;
if (fine > 0.) {
fine = fine * 10.0;
}
if (fine > 0.3) {
float fine_blink_fade = texture(noise_sparse, (FRAGCOORD.xy + blink_scroll*TIME)*noise_sparse_scale).r;
fine = fine - ((fine_blink_fade * fine_blink_fade) - 0.2) * 1.2;
}
vec4 clouds = vec4(vec3(0.3, 0.5, 0.7) * sparse, 1.0);
vec4 stars = vec4(fine);
COLOR = clouds + stars;
}"
[sub_resource type="OpenSimplexNoise" id=2]
period = 2.0
persistence = 0.6
lacunarity = 3.0
[sub_resource type="NoiseTexture" id=3]
seamless = true
noise = SubResource( 2 )
[sub_resource type="OpenSimplexNoise" id=4]
[sub_resource type="NoiseTexture" id=5]
width = 1024
height = 1024
seamless = true
noise = SubResource( 4 )
[resource]
shader = SubResource( 1 )
shader_param/noise_sparse = SubResource( 5 )
shader_param/noise_fine = SubResource( 3 )

View file

@ -1,54 +1,52 @@
[gd_resource type="TileSet" load_steps=5 format=2] [gd_resource type="TileSet" load_steps=3 format=2]
[ext_resource path="res://Graphics/tgstation/wall.png" type="Texture" id=2] [ext_resource path="res://Graphics/tgstation/walls_tiled.png" type="Texture" id=1]
[ext_resource path="res://Graphics/tgstation/window.png" type="Texture" id=3] [ext_resource path="res://Graphics/tgstation/windows_tiled.png" type="Texture" id=4]
[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 32, 32, 0, 32, 0, 0, 32, 0 )
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[resource] [resource]
2/name = "Wall" 4/name = "Wall"
2/texture = ExtResource( 2 ) 4/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 ) 4/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 ) 4/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 0, 0, 32, 32 ) 4/region = Rect2( 0, 0, 256, 224 )
2/tile_mode = 0 4/tile_mode = 1
2/occluder_offset = Vector2( 0, 0 ) 4/autotile/bitmask_mode = 1
2/navigation_offset = Vector2( 0, 0 ) 4/autotile/bitmask_flags = [ Vector2( 0, 0 ), 176, Vector2( 0, 1 ), 178, Vector2( 0, 2 ), 50, Vector2( 0, 3 ), 442, Vector2( 0, 4 ), 190, Vector2( 0, 5 ), 434, Vector2( 0, 6 ), 182, Vector2( 1, 0 ), 184, Vector2( 1, 1 ), 186, Vector2( 1, 2 ), 58, Vector2( 1, 3 ), 250, Vector2( 1, 4 ), 187, Vector2( 1, 5 ), 218, Vector2( 1, 6 ), 155, Vector2( 2, 0 ), 152, Vector2( 2, 1 ), 154, Vector2( 2, 2 ), 26, Vector2( 2, 3 ), 464, Vector2( 2, 4 ), 23, Vector2( 2, 5 ), 440, Vector2( 2, 6 ), 62, Vector2( 3, 0 ), 144, Vector2( 3, 1 ), 146, Vector2( 3, 2 ), 18, Vector2( 3, 3 ), 16, Vector2( 3, 4 ), 510, Vector2( 3, 5 ), 248, Vector2( 3, 6 ), 59, Vector2( 4, 0 ), 48, Vector2( 4, 1 ), 432, Vector2( 4, 2 ), 438, Vector2( 4, 3 ), 54, Vector2( 4, 4 ), 507, Vector2( 4, 5 ), 447, Vector2( 4, 6 ), 255, Vector2( 5, 0 ), 56, Vector2( 5, 1 ), 504, Vector2( 5, 2 ), 511, Vector2( 5, 3 ), 63, Vector2( 5, 4 ), 308, Vector2( 5, 5 ), 254, Vector2( 5, 6 ), 443, Vector2( 6, 0 ), 24, Vector2( 6, 1 ), 216, Vector2( 6, 2 ), 219, Vector2( 6, 3 ), 27, Vector2( 6, 4 ), 89, Vector2( 6, 5 ), 443, Vector2( 6, 6 ), 254, Vector2( 7, 0 ), 251, Vector2( 7, 1 ), 446, Vector2( 7, 2 ), 191, Vector2( 7, 3 ), 506 ]
2/shape_offset = Vector2( 0, 0 ) 4/autotile/icon_coordinate = Vector2( 3, 3 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 4/autotile/tile_size = Vector2( 32, 32 )
2/shape = SubResource( 1 ) 4/autotile/spacing = 0
2/shape_one_way = false 4/autotile/occluder_map = [ ]
2/shape_one_way_margin = 1.0 4/autotile/navpoly_map = [ ]
2/shapes = [ { 4/autotile/priority_map = [ ]
"autotile_coord": Vector2( 0, 0 ), 4/autotile/z_index_map = [ ]
"one_way": false, 4/occluder_offset = Vector2( 0, 0 )
"one_way_margin": 1.0, 4/navigation_offset = Vector2( 0, 0 )
"shape": SubResource( 1 ), 4/shape_offset = Vector2( 0, 0 )
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
} ] 4/shape_one_way = false
2/z_index = 0 4/shape_one_way_margin = 0.0
3/name = "Window" 4/shapes = [ ]
3/texture = ExtResource( 3 ) 4/z_index = 0
3/tex_offset = Vector2( 0, 0 ) 5/name = "Window"
3/modulate = Color( 1, 1, 1, 1 ) 5/texture = ExtResource( 4 )
3/region = Rect2( 0, 0, 32, 32 ) 5/tex_offset = Vector2( 0, 0 )
3/tile_mode = 0 5/modulate = Color( 1, 1, 1, 1 )
3/occluder_offset = Vector2( 0, 0 ) 5/region = Rect2( 0, 0, 256, 224 )
3/navigation_offset = Vector2( 0, 0 ) 5/tile_mode = 1
3/shape_offset = Vector2( 0, 0 ) 5/autotile/bitmask_mode = 1
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 5/autotile/bitmask_flags = [ Vector2( 0, 0 ), 176, Vector2( 0, 1 ), 178, Vector2( 0, 2 ), 50, Vector2( 0, 3 ), 442, Vector2( 0, 4 ), 190, Vector2( 0, 5 ), 434, Vector2( 0, 6 ), 182, Vector2( 1, 0 ), 184, Vector2( 1, 1 ), 186, Vector2( 1, 2 ), 58, Vector2( 1, 3 ), 250, Vector2( 1, 4 ), 187, Vector2( 1, 5 ), 218, Vector2( 1, 6 ), 155, Vector2( 2, 0 ), 152, Vector2( 2, 1 ), 154, Vector2( 2, 2 ), 26, Vector2( 2, 3 ), 464, Vector2( 2, 4 ), 23, Vector2( 2, 5 ), 440, Vector2( 2, 6 ), 62, Vector2( 3, 0 ), 144, Vector2( 3, 1 ), 146, Vector2( 3, 2 ), 18, Vector2( 3, 3 ), 16, Vector2( 3, 4 ), 510, Vector2( 3, 5 ), 248, Vector2( 3, 6 ), 59, Vector2( 4, 0 ), 48, Vector2( 4, 1 ), 432, Vector2( 4, 2 ), 438, Vector2( 4, 3 ), 54, Vector2( 4, 4 ), 507, Vector2( 4, 5 ), 447, Vector2( 4, 6 ), 255, Vector2( 5, 0 ), 56, Vector2( 5, 1 ), 504, Vector2( 5, 2 ), 511, Vector2( 5, 3 ), 63, Vector2( 5, 4 ), 308, Vector2( 5, 5 ), 254, Vector2( 5, 6 ), 443, Vector2( 6, 0 ), 24, Vector2( 6, 1 ), 216, Vector2( 6, 2 ), 219, Vector2( 6, 3 ), 27, Vector2( 6, 4 ), 89, Vector2( 6, 5 ), 443, Vector2( 6, 6 ), 254, Vector2( 7, 0 ), 251, Vector2( 7, 1 ), 446, Vector2( 7, 2 ), 191, Vector2( 7, 3 ), 506 ]
3/shape = SubResource( 2 ) 5/autotile/icon_coordinate = Vector2( 3, 3 )
3/shape_one_way = false 5/autotile/tile_size = Vector2( 32, 32 )
3/shape_one_way_margin = 1.0 5/autotile/spacing = 0
3/shapes = [ { 5/autotile/occluder_map = [ ]
"autotile_coord": Vector2( 0, 0 ), 5/autotile/navpoly_map = [ ]
"one_way": false, 5/autotile/priority_map = [ ]
"one_way_margin": 1.0, 5/autotile/z_index_map = [ ]
"shape": SubResource( 2 ), 5/occluder_offset = Vector2( 0, 0 )
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) 5/navigation_offset = Vector2( 0, 0 )
} ] 5/shape_offset = Vector2( 0, 0 )
3/z_index = 0 5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
5/shape_one_way = false
5/shape_one_way_margin = 0.0
5/shapes = [ ]
5/z_index = 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/walls_tiled.png-e9af388078750e44e8d744c580c0c4d5.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/tgstation/walls_tiled.png"
dest_files=[ "res://.import/walls_tiled.png-e9af388078750e44e8d744c580c0c4d5.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/windows_tiled.png-2e919e68bf2e5f8f08c847994c524d05.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/tgstation/windows_tiled.png"
dest_files=[ "res://.import/windows_tiled.png-2e919e68bf2e5f8f08c847994c524d05.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,13 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
content_margin_left = 5.0
content_margin_right = 5.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0.6, 0.6, 0.6, 0.392157 )
corner_radius_top_left = 2
corner_radius_top_right = 2
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2
anti_aliasing = false

View file

@ -0,0 +1,7 @@
[gd_resource type="StyleBoxEmpty" format=2]
[resource]
content_margin_left = 5.0
content_margin_right = 5.0
content_margin_top = 5.0
content_margin_bottom = 5.0

View file

@ -0,0 +1,19 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
content_margin_left = 5.0
content_margin_right = 5.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0.196078, 0.180392, 0.313726, 1 )
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.54902, 0.54902, 0.576471, 0.784314 )
corner_radius_top_left = 2
corner_radius_top_right = 2
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2
corner_detail = 4
anti_aliasing = false

20
Scenes/Editor/TileTab.gd Normal file
View file

@ -0,0 +1,20 @@
extends ScrollContainer
class_name TileTab
const button_theme = preload("res://Scenes/Editor/ToolButtonTheme.tres")
signal tile_selected(id)
func add_entry(id: int, group: ButtonGroup, icon: Texture):
var node := ToolButton.new()
node.toggle_mode = true
node.icon = icon
node.group = group
node.flat = false
node.theme = button_theme
node.connect("pressed", self, "_pressed", [id])
$list.add_child(node)
func _pressed(id: int):
emit_signal("tile_selected", id)

View file

@ -0,0 +1,18 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/Editor/TileTab.gd" type="Script" id=1]
[node name="TileTab" type="ScrollContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="list" type="HBoxContainer" parent="."]
margin_right = 1280.0
margin_bottom = 800.0
size_flags_horizontal = 3
size_flags_vertical = 3

View file

@ -0,0 +1,28 @@
[gd_resource type="Theme" load_steps=7 format=2]
[ext_resource path="res://Scenes/Editor/Styles/ToolNormal.tres" type="StyleBox" id=1]
[ext_resource path="res://Scenes/Editor/Styles/ToolPressed.tres" type="StyleBox" id=2]
[ext_resource path="res://Scenes/Editor/Styles/ToolHover.tres" type="StyleBox" id=3]
[sub_resource type="DynamicFontData" id=1]
font_path = "res://Graphics/UI/iosevka-aile-regular.ttf"
[sub_resource type="DynamicFont" id=2]
size = 12
use_mipmaps = true
font_data = SubResource( 1 )
[sub_resource type="StyleBoxEmpty" id=3]
[resource]
ToolButton/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
ToolButton/colors/font_color_disabled = Color( 0.9, 0.95, 1, 0.3 )
ToolButton/colors/font_color_hover = Color( 0.94, 0.94, 0.94, 1 )
ToolButton/colors/font_color_pressed = Color( 1, 1, 1, 1 )
ToolButton/constants/hseparation = 3
ToolButton/fonts/font = SubResource( 2 )
ToolButton/styles/disabled = null
ToolButton/styles/focus = SubResource( 3 )
ToolButton/styles/hover = ExtResource( 3 )
ToolButton/styles/normal = ExtResource( 1 )
ToolButton/styles/pressed = ExtResource( 2 )

View file

@ -4,13 +4,13 @@ class_name GameInstance
signal state_received() signal state_received()
onready var ui = $CanvasLayer/ui onready var ui := $CanvasLayer/ui
onready var world = $world onready var world := $world as GameWorld
onready var systems = $systems onready var systems := $systems as GameSystems
onready var netgame = $"/root/Multiplayer" onready var netgame := $"/root/Multiplayer"
onready var physics = world.get_world_2d().direct_space_state as Physics2DDirectSpaceState onready var physics := world.get_world_2d().direct_space_state as Physics2DDirectSpaceState
var writing = false var writing := false
func _ready() -> void: func _ready() -> void:
$"/root/Music/BGM".stop() $"/root/Music/BGM".stop()
@ -18,7 +18,7 @@ func _ready() -> void:
if netgame.hosting: if netgame.hosting:
world.load_map(netgame.get_current_map()) world.load_map(netgame.get_current_map())
world.map.current_ship_position = Vector2(randf() * 1e4, randf() * 1e4) world.map.current_ship_position = Vector2(randf() * 1e4, randf() * 1e4)
world.map.current_ship_target = world.map.current_ship_position + Vector2(randf() * 1e2, randf() * 1e2) world.map.current_ship_target = null
rpc("spawn_player", 1) rpc("spawn_player", 1)
else: else:
world.load_map(GameWorld.Map.EMPTY) world.load_map(GameWorld.Map.EMPTY)
@ -27,9 +27,9 @@ func _ready() -> void:
rpc_id(1, "ready_to_spawn") rpc_id(1, "ready_to_spawn")
master func send_map() -> void: master func send_map() -> void:
var id = get_tree().get_rpc_sender_id() var id := get_tree().get_rpc_sender_id()
var map_data = world.map.serialize() var map_data := (world.map as GameMap).serialize()
var systems_data = systems.serialize() var systems_data := systems.serialize()
print("sending map data to %d" % id) print("sending map data to %d" % id)
rpc_id(id, "receive_data", { rpc_id(id, "receive_data", {
"map": map_data, "map": map_data,
@ -43,11 +43,11 @@ puppet func receive_data(data: Dictionary) -> void:
emit_signal("state_received") emit_signal("state_received")
master func ready_to_spawn() -> void: 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) print("%d is ready to spawn players" % id)
# Tell him everyone to spawn # Tell him everyone to spawn
var players = $world/players.get_children() var players := $world/players.get_children()
for player in players: for player in players:
rpc_id(id, "spawn_player", player.get_network_master()) rpc_id(id, "spawn_player", player.get_network_master())
@ -55,15 +55,15 @@ master func ready_to_spawn() -> void:
rpc("spawn_player", id) rpc("spawn_player", id)
master func broadcast_zone(message: String, origin: Vector2, radius: float) -> void: master func broadcast_zone(message: String, origin: Vector2, radius: float) -> void:
var shape = CircleShape2D.new() var shape := CircleShape2D.new()
shape.radius = radius shape.radius = radius
var query = Physics2DShapeQueryParameters.new() var query := Physics2DShapeQueryParameters.new()
query.collide_with_areas = true query.collide_with_areas = true
query.collide_with_bodies = false query.collide_with_bodies = false
query.collision_layer = 32 query.collision_layer = 32
query.transform.origin = origin query.transform.origin = origin
query.set_shape(shape) query.set_shape(shape)
var res = physics.intersect_shape(query, 100) var res := physics.intersect_shape(query, 100)
for col in res: for col in res:
rpc_id(col.collider.get_network_master(), "add_log", message) rpc_id(col.collider.get_network_master(), "add_log", message)

View file

@ -4,32 +4,32 @@ signal ms_updated(action, data)
signal left() signal left()
# Hosting info # Hosting info
const SERVER_PORT = 5513 const SERVER_PORT := 5513
const MAX_PLAYERS = 30 const MAX_PLAYERS := 30
var port = SERVER_PORT var port := SERVER_PORT
# Throttle network updates of often-changed variables by this many physics frames # 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 # Master server data
const MASTER_SERVER_ADDR = "fgms.zyg.ovh" const MASTER_SERVER_ADDR := "fgms.zyg.ovh"
const MASTER_SERVER_UDP_PORT = 9434 const MASTER_SERVER_UDP_PORT := 9434
const MS_GAME_CODE = "odyssey-0-a2" const MS_GAME_CODE := "odyssey-0-a2"
const GOTM_OVERRIDE = false const GOTM_OVERRIDE := false
# Master server entry # Master server entry
var ms_active = false var ms_active := false
var ms_key = "" var ms_key := ""
var server_name = "" var server_name := ""
var hosting = false var hosting := false
export var player_name = "" export var player_name := ""
var player_info = {} var player_info := {}
var round_info = {} var round_info := {}
onready var scene_manager = $"/root/SceneManager" onready var scene_manager := $"/root/SceneManager"
func _ready(): func _ready():
randomize() randomize()
@ -62,7 +62,7 @@ func punch_nat():
socketUDP.close() socketUDP.close()
func discover_upnp(): func discover_upnp():
var upnp = UPNP.new() var upnp := UPNP.new()
upnp.discover(2000, 2, "InternetGatewayDevice") upnp.discover(2000, 2, "InternetGatewayDevice")
return upnp.add_port_mapping(SERVER_PORT) return upnp.add_port_mapping(SERVER_PORT)
@ -86,9 +86,9 @@ func host(map_name: String = "odyssey"):
round_info = { "map": map_name } round_info = { "map": map_name }
bind_events() bind_events()
var peer = NetworkedMultiplayerENet.new() var peer := NetworkedMultiplayerENet.new()
peer.compression_mode = NetworkedMultiplayerENet.COMPRESS_FASTLZ 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: if server_res != OK:
match server_res: match server_res:
ERR_CANT_CREATE: ERR_CANT_CREATE:
@ -127,7 +127,7 @@ func join(server):
print("Connecting to %s" % addr) print("Connecting to %s" % addr)
func leave(): func leave():
var peer = get_tree().network_peer var peer := get_tree().network_peer
if get_tree().is_network_server(): if get_tree().is_network_server():
# Tell MS we're leaving # Tell MS we're leaving
if ms_active: if ms_active:
@ -160,7 +160,7 @@ func _connected_fail():
push_warning("Connection failed") push_warning("Connection failed")
remote func register_player(username: String): 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 } player_info[id] = { name=username }
print("%s (%d) connected" % [player_info[id].name, id]) print("%s (%d) connected" % [player_info[id].name, id])
@ -169,7 +169,7 @@ remote func _handshake(infos):
player_info = infos["players"] player_info = infos["players"]
func _ms_request(endpoint: String, data): func _ms_request(endpoint: String, data):
var http_request = HTTPRequest.new() var http_request := HTTPRequest.new()
add_child(http_request) add_child(http_request)
http_request.connect("request_completed", self, "_ms_response", [endpoint]) http_request.connect("request_completed", self, "_ms_response", [endpoint])
print_debug("Telling ms to %s" % 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.") push_error("An error occurred in the HTTP request.")
func ms_get_entries(): func ms_get_entries():
var http_request = HTTPRequest.new() var http_request := HTTPRequest.new()
add_child(http_request) add_child(http_request)
http_request.connect("request_completed", self, "_ms_response", ["list_games"]) http_request.connect("request_completed", self, "_ms_response", ["list_games"])
var error = http_request.request( var error = http_request.request(
@ -226,7 +226,7 @@ func _ms_response(_result: int, response_code: int, _headers: PoolStringArray, b
if response_code > 299: if response_code > 299:
push_error("ms action '%s' returned error: %s - %s" % [action, response_code, body.get_string_from_utf8()]) push_error("ms action '%s' returned error: %s - %s" % [action, response_code, body.get_string_from_utf8()])
return return
var json = JSON.parse(body.get_string_from_utf8()) var json := JSON.parse(body.get_string_from_utf8())
match action: match action:
"new": "new":
if json.result.ok: if json.result.ok:

37
Scenes/InEditorMap.gd Normal file
View file

@ -0,0 +1,37 @@
extends Node2D
var debug_areas := false
const ProbeElectricity := preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
onready var tilemaps := [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
onready var pois := $pois
func _ready():
pass
# Run autotile conversions and generate occlusions
#$tiles/walls.run_conversions()
# Electricity setup
#make_electric_probes($tiles/cables, "Wire")
# Tileset related functions
func make_electric_probes(tilemap: TileMap, tile_name: String):
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()
probe.position = coord
tilemap.add_child(probe)
func get_pois(type_filter, class_filter) -> Array:
var filtered := []
for child in $pois.get_children():
if type_filter != null and child.poitype != type_filter:
continue
if class_filter != null and child.poiclass != class_filter:
continue
filtered.append(child)
return filtered

View file

@ -1,7 +1,7 @@
extends Control extends Control
onready var text = $BottomRight/Label onready var text := $BottomRight/Label
onready var scene_manager = $"/root/SceneManager" onready var scene_manager := $"/root/SceneManager"
func _physics_process(_delta): func _physics_process(_delta):
text.text = str(scene_manager.get_progress()) text.text = str(scene_manager.get_progress())

View file

@ -3,71 +3,75 @@ extends Node2D
class_name GameMap class_name GameMap
var debug_areas = false var debug_areas := false
var ship_direction = 0 var ship_direction := 0
var ship_speed = 0 var ship_speed := 0
var current_ship_position = Vector2.ZERO var current_ship_position := Vector2.ZERO
var current_ship_subpos = Vector2.ZERO var current_ship_subpos := Vector2.ZERO
var current_ship_target = Vector2.ZERO var current_ship_target = Vector2.ZERO
var current_ship_direction = 0.0 var current_ship_direction := 0.0
var current_ship_speed = 0.0 var current_ship_speed := 0.0
puppet var pup_ship_position = Vector2.ZERO var deepspace_mat: ShaderMaterial = null
puppet var pup_ship_subpos = Vector2.ZERO var warp_state := false
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 puppet var pup_ship_position := Vector2.ZERO
const MAX_STEERING = 0.06 puppet var pup_ship_subpos := Vector2.ZERO
const EPSILON = 1e-3 puppet var pup_ship_target := Vector2.ZERO
const SCROLL_MULTIPLIER = 1e4 puppet var pup_ship_direction := 0.0
const ENGINE_MULTIPLIER = 5000 puppet var pup_ship_speed := 0.0
const NO_SPEED_THRESHOLD = 0.01
const ProbeElectricity = preload("res://Actors/Systems/Electricity/ElectricProbe.tscn") 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
onready var tilemaps = [ $base, $cables, $floor, $walls ] const ProbeElectricity := preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
onready var pois = $pois onready var tilemaps := [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
export var unlit = false setget set_unlit onready var pois := $pois
onready var darkness = $darkness
export var shadow_intensity = 0.2 export var unlit := false setget set_unlit
onready var darkness := $darkness
export var shadow_intensity := 0.2
func _ready(): func _ready():
if Engine.editor_hint: if Engine.editor_hint:
return return
$editor.queue_free()
set_unlit(true) set_unlit(true)
if not is_network_master(): if not is_network_master():
return return
# Run autotile conversions and generate occlusions # Run autotile conversions and generate occlusions
$walls.run_conversions() $tiles/walls.run_conversions()
# Electricity setup # Electricity setup
make_electric_probes($cables, "Wire") make_electric_probes($tiles/cables, "Wire")
# Set engines to expected power level # Set engines to expected power level
set_engine_strength(current_ship_speed) set_engine_strength(current_ship_speed)
deepspace_mat = $deepspace.material as ShaderMaterial
func _process(delta: float): func _process(delta: float):
if Engine.editor_hint: if Engine.editor_hint:
return return
var engines = get_engine_count() var engines := get_engine_count()
var max_speed = get_max_speed() var max_speed := get_max_speed()
# Ease ship speed/direction changes # Ease ship speed/direction changes
if abs(current_ship_direction) > PI*2: if abs(current_ship_direction) > PI*2:
current_ship_direction -= PI*2 * sign(current_ship_direction) 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: if direction_delta < 0:
direction_delta += PI*2 direction_delta += PI*2
if direction_delta > PI: if direction_delta > PI:
@ -79,26 +83,25 @@ func _process(delta: float):
# Avoid stuttering by not turning until there's enough reason to # Avoid stuttering by not turning until there's enough reason to
if abs(direction_delta) > 0.1: if abs(direction_delta) > 0.1:
current_ship_direction += MAX_STEERING * engines * delta * sign(direction_delta) 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: if abs(speed_delta) < EPSILON:
current_ship_speed = ship_speed current_ship_speed = ship_speed
else: else:
current_ship_speed += MAX_ACCELERATION * max_speed * delta * sign(speed_delta) current_ship_speed += MAX_ACCELERATION * max_speed * delta * sign(speed_delta)
set_engine_strength(current_ship_speed * ENGINE_MULTIPLIER) set_engine_strength(current_ship_speed * ENGINE_MULTIPLIER)
$deepspace.rotation = -current_ship_direction-PI/2 deepspace_mat.set_shader_param("scroll_speed", current_ship_speed * 5000)
$deepspace.region_rect.position += Vector2(-sin(current_ship_direction), cos(current_ship_direction)) * current_ship_speed * SCROLL_MULTIPLIER * delta
func _physics_process(delta): func _physics_process(delta):
if Engine.editor_hint: if Engine.editor_hint:
return return
if is_network_master(): 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: 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: if distance > NO_SPEED_THRESHOLD:
ship_direction = current_ship_target.angle_to_point(adj_position) 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: if max_speed > 0:
var deceleration_time = current_ship_speed / (MAX_ACCELERATION * max_speed) var deceleration_time = current_ship_speed / (MAX_ACCELERATION * max_speed)
if current_ship_speed * deceleration_time < distance: if current_ship_speed * deceleration_time < distance:
@ -113,18 +116,24 @@ func _physics_process(delta):
ship_speed = 0.0 ship_speed = 0.0
rset("pup_ship_speed", ship_speed) rset("pup_ship_speed", ship_speed)
if current_ship_speed > EPSILON: 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 current_ship_subpos += pos_delta
if current_ship_subpos.x >= 1.0: 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_position.x += int_part
current_ship_subpos.x -= int_part current_ship_subpos.x -= int_part
if current_ship_subpos.y >= 1.0: 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_position.y += int_part
current_ship_subpos.y -= int_part current_ship_subpos.y -= int_part
rset("pup_ship_position", current_ship_position) rset("pup_ship_position", current_ship_position)
rset("pup_ship_subpos", current_ship_subpos) rset("pup_ship_subpos", current_ship_subpos)
if not warp_state and current_ship_speed > 0.05:
# Engage FTL
rpc("warp_enter")
elif warp_state and current_ship_speed < 0.02:
# Diseangage FTL
rpc("warp_exit")
else: else:
ship_speed = 0.0 ship_speed = 0.0
rset("pup_ship_speed", ship_speed) rset("pup_ship_speed", ship_speed)
@ -134,18 +143,18 @@ func _physics_process(delta):
current_ship_position = pup_ship_position current_ship_position = pup_ship_position
current_ship_subpos = pup_ship_subpos current_ship_subpos = pup_ship_subpos
func get_engine_count(): func get_engine_count() -> int:
var working_engines = 0 var working_engines := 0
for child in $engines.get_children(): for child in $engines.get_children():
var engine = child as GameObjectEngine var engine := child as GameObjectEngine
if engine.force > 0: if engine.force > 0:
working_engines += 1 working_engines += 1
return working_engines return working_engines
func get_max_speed(): func get_max_speed() -> float:
var max_speed = 0 var max_speed := 0.0
for child in $engines.get_children(): for child in $engines.get_children():
var engine = child as GameObjectEngine var engine := child as GameObjectEngine
max_speed += engine.force max_speed += engine.force
return max_speed return max_speed
@ -153,9 +162,9 @@ func get_max_speed():
func serialize() -> Dictionary: func serialize() -> Dictionary:
# Get tilemap data # Get tilemap data
var tilemapdata = {} var tilemapdata := {}
for tilemap in tilemaps: for tilemap in tilemaps:
var data = [] var data := []
for cell in tilemap.get_used_cells(): for cell in tilemap.get_used_cells():
data.append([cell, tilemap.get_cellv(cell)]) data.append([cell, tilemap.get_cellv(cell)])
tilemapdata[tilemap.name] = data tilemapdata[tilemap.name] = data
@ -205,10 +214,10 @@ func deserialize(data: Dictionary) -> void:
current_ship_direction = data["ship"]["direction"] current_ship_direction = data["ship"]["direction"]
# Run autotile conversions and generate occlusions # Run autotile conversions and generate occlusions
$walls.run_conversions() $tiles/walls.run_conversions()
func serialize_children(node: Node) -> Dictionary: func serialize_children(node: Node) -> Dictionary:
var data = {} var data := {}
for child in node.get_children(): for child in node.get_children():
data[child.name] = { data[child.name] = {
"filename": child.filename, "filename": child.filename,
@ -219,7 +228,7 @@ func serialize_children(node: Node) -> Dictionary:
func deserialize_children(node: Node, data: Dictionary, deserialize_first: bool = false) -> void: func deserialize_children(node: Node, data: Dictionary, deserialize_first: bool = false) -> void:
for node_name in data: 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() var node_scene = load(node_data.filename).instance()
node_scene.name = node_name node_scene.name = node_name
node_scene.transform = node_data.transform node_scene.transform = node_data.transform
@ -242,21 +251,29 @@ func set_engine_strength(val: float):
# Set energy strength to current speed # Set energy strength to current speed
for child in $engines.get_children(): for child in $engines.get_children():
if child is GameObjectEngine: if child is GameObjectEngine:
var engine = child as GameObjectEngine var engine := child as GameObjectEngine
engine.strength = val engine.strength = val
remotesync func warp_enter():
$deepspace/AnimationPlayer.play("warp-enter")
warp_state = true
remotesync func warp_exit():
$deepspace/AnimationPlayer.play("warp-exit")
warp_state = false
# Tileset related functions # Tileset related functions
func make_electric_probes(tilemap: TileMap, tile_name: String): 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): for cell in tilemap.get_used_cells_by_id(tile_id):
var coord = tilemap.map_to_world(cell) var coord := tilemap.map_to_world(cell)
var probe = ProbeElectricity.instance() var probe := ProbeElectricity.instance()
probe.position = coord probe.position = coord
tilemap.add_child(probe) tilemap.add_child(probe)
func get_pois(type_filter, class_filter) -> Array: func get_pois(type_filter, class_filter) -> Array:
var filtered = [] var filtered := []
for child in $pois.get_children(): for child in $pois.get_children():
if type_filter != null and child.poitype != type_filter: if type_filter != null and child.poitype != type_filter:
continue continue

349
Scenes/MapEditor.gd Normal file
View file

@ -0,0 +1,349 @@
extends Control
onready var map_menu := ($menu/menubar/MapMenu as MenuButton).get_popup()
onready var map_node := $map
onready var cursor := $map/cursor
onready var cursor_sprite := $map/cursor/preview
const MAP_SCALE_MAX := 8.0
const MAP_SCALE_MIN := 0.25
const TileTabScene := preload("res://Scenes/Editor/TileTab.tscn")
const objects = {
"Machines": [
GameObjectComputer,
GameObjectDoor,
GameObjectEngine,
GameObjectLightbulb,
GameObjectPowerStorage
]
}
func _ready():
# Add tiles
add_tile_tab("Base", $map/tiles/base)
add_tile_tab("Cables", $map/tiles/cables)
add_tile_tab("Floors", $map/tiles/floor)
add_tile_tab("Walls", $map/tiles/walls)
# Add objects
for cat in objects:
add_object_list(cat, objects[cat])
enum PlacingMode {
NONE,
TILEMAP,
OBJECT
}
enum Tool {
NONE
TILE_FREEHAND,
TILE_RECT,
TILE_FILL,
OBJ_PLACE,
OBJ_EDIT,
OBJ_REMOVE
}
# Prevent input handler from running when other dialogs/actions are focused
var input_lock := false
# Drag variables
var dragging := false
var view_origin := Vector2.ZERO
var mouse_origin := Vector2.ZERO
# Placing variables
var placing := false
var deleting := false
var placing_mode = PlacingMode.NONE
var placing_layer = null
var placing_tile_id := -1
var current_tool = Tool.NONE
# Cursor variables
var cursor_pos := Vector2.ZERO
var pressed_pos := Vector2.ZERO
const TILE_SIZE := 32
func _input(ev: InputEvent):
if input_lock:
return
if ev is InputEventMouseMotion:
if dragging:
map_node.global_position = view_origin - (mouse_origin - ev.global_position)
else:
# Map cursor location to grid
var tile_snap: Vector2 = map_node.scale * TILE_SIZE
var mouse_offset: Vector2 = (ev.global_position - map_node.global_position) / tile_snap
var new_cursor_pos := Vector2(floor(mouse_offset.x), floor(mouse_offset.y))
if new_cursor_pos != cursor_pos:
var old_pos = cursor_pos
cursor_pos = new_cursor_pos
if placing or deleting:
if current_tool != Tool.NONE:
tile_mouse_move(old_pos, cursor_pos)
cursor.position = cursor_pos * TILE_SIZE
if ev is InputEventMouseButton:
var mouse := ev as InputEventMouseButton
if mouse.pressed:
match ev.button_index:
BUTTON_LEFT, BUTTON_RIGHT:
if current_tool != Tool.NONE:
tile_pressed(ev.button_index, cursor_pos)
BUTTON_WHEEL_UP:
# Zoom in
var old_scale = map_node.scale
if map_node.scale.x < MAP_SCALE_MAX:
if map_node.scale.x < 1:
map_node.scale *= 2
else:
map_node.scale += Vector2.ONE
map_node.position -= (map_node.position + mouse.position * map_node.scale)- (map_node.position + mouse.position * old_scale)
BUTTON_WHEEL_DOWN:
# Zoom out
var old_scale = map_node.scale
if map_node.scale.x > MAP_SCALE_MIN:
if map_node.scale.x <= 1:
map_node.scale /= 2
else:
map_node.scale -= Vector2.ONE
map_node.position -= (map_node.position + mouse.position * map_node.scale)- (map_node.position + mouse.position * old_scale)
BUTTON_MIDDLE:
view_origin = map_node.global_position
mouse_origin = ev.global_position
dragging = true
else:
match ev.button_index:
BUTTON_LEFT, BUTTON_RIGHT:
if current_tool != Tool.NONE:
tile_released(ev.button_index, cursor_pos)
BUTTON_MIDDLE:
dragging = false
map_node.global_position = view_origin - (mouse_origin - ev.global_position)
func place_rect(a: Vector2, b: Vector2, id: int):
if placing_layer == null:
return
var layer := placing_layer as TileMap
# Sort coordinates
var x_ord = Vector2(a.x, b.x)
var y_ord = Vector2(a.y, b.y)
if a.x > b.x:
x_ord = Vector2(b.x, a.x)
if a.y > b.y:
y_ord = Vector2(b.y, a.y)
for x in range(x_ord.x, x_ord.y+1):
place_tile(layer, Vector2(x, a.y), id)
place_tile(layer, Vector2(x, b.y), id)
for y in range(y_ord.x, y_ord.y+1):
place_tile(layer, Vector2(a.x, y), id)
place_tile(layer, Vector2(b.x, y), id)
layer.update_bitmask_region(a, b)
func place_tile(tilemap: TileMap, pos: Vector2, id: int):
# Place tile
tilemap.set_cellv(pos, id)
# If no base is under that tile, add it
if id != -1 and tilemap != $map/tiles/base:
if $map/tiles/base.get_cellv(pos) == -1:
$map/tiles/base.set_cellv(pos, 1)
func place_tiles(tilemap: TileMap, positions: Array, id: int):
for pos in positions:
place_tile(tilemap, pos, id)
for pos in positions:
# Update bitmask
tilemap.update_bitmask_area(pos)
var group := ButtonGroup.new()
func add_tile_tab(name: String, tilemap: TileMap):
var tab := add_tab(name)
tab.connect("tile_selected", self, "_tile_selected", [name, tilemap])
var tileset := tilemap.tile_set
var ids := tileset.get_tiles_ids()
for id in ids:
var tile_icon := make_tile_texture(tileset, id)
tab.add_entry(id, group, tile_icon)
func add_tab(name: String) -> TileTab:
var tab := TileTabScene.instance() as TileTab
tab.name = name
$layers/tabs.add_child(tab)
return tab
func add_object_list(name: String, objects: Array):
var tab := ItemList.new()
tab.connect("item_selected", self, "_item_selected", [tab])
tab.name = name
for obj in objects:
var editor_info = obj.editor_info()
tab.add_item(editor_info.name, editor_info.icon)
tab.set_item_metadata(tab.get_item_count()-1, editor_info)
$objects/tabs.add_child(tab)
func _item_selected(idx: int, tab: ItemList):
var meta = tab.get_item_metadata(idx)
cursor_sprite.texture = meta.icon
func _toggle_tile_input(enable: bool):
input_lock = not enable
func _tile_selected(id: int, _name: String, tilemap: TileMap):
cursor_sprite.texture = make_tile_texture(tilemap.tile_set, id)
placing_mode = PlacingMode.TILEMAP
placing_layer = tilemap
placing_tile_id = id
func make_tile_texture(tileset: TileSet, id: int) -> AtlasTexture:
var tile_mode := tileset.tile_get_tile_mode(id)
var tile_icon := AtlasTexture.new()
tile_icon.atlas = tileset.tile_get_texture(id)
match tile_mode:
TileSet.AUTO_TILE:
var tile_size := tileset.autotile_get_size(id)
tile_icon.region = Rect2(
tileset.autotile_get_icon_coordinate(id) * tile_size,
tile_size
)
TileSet.SINGLE_TILE:
tile_icon.region = tileset.tile_get_region(id)
return tile_icon
onready var layers_panel = $layers
onready var objects_panel = $objects
onready var brush_panel = $tools/brushPanel
onready var obj_action_panel = $tools/objPanel
func _tool_selected(tool_type):
layers_panel.visible = false
brush_panel.visible = false
objects_panel.visible = false
obj_action_panel.visible = false
placing_mode = PlacingMode.NONE
match tool_type:
"tile":
layers_panel.visible = tool_type(current_tool) == "brush"
brush_panel.visible = true
placing_mode = PlacingMode.TILEMAP
"obj":
obj_action_panel.visible = true
objects_panel.visible = tool_type(current_tool) == "obj"
placing_mode = PlacingMode.OBJECT
func _set_brush(brush_type: String):
match brush_type:
"freehand":
current_tool = Tool.TILE_FREEHAND
"rect":
current_tool = Tool.TILE_RECT
"fill":
current_tool = Tool.TILE_FILL
layers_panel.visible = true
func tool_type(brush):
match brush:
Tool.TILE_FILL, Tool.TILE_FREEHAND, Tool.TILE_RECT:
return "brush"
Tool.OBJ_EDIT, Tool.OBJ_PLACE, Tool.OBJ_REMOVE:
return "obj"
_:
return "none"
var ff_cells = {}
var ff_origin = Vector2.ZERO
const BOUNDS_MAX_X = 40
const BOUNDS_MAX_Y = 40
# Sanity check: force bounds for cell
func ff_is_inbound(cell: Vector2):
return abs(cell.x-ff_origin.x) < BOUNDS_MAX_X and abs(cell.y-ff_origin.y) < BOUNDS_MAX_Y
func ff_is_valid(tilemap: TileMap, cell: Vector2, matching_tile: int) -> bool:
return ff_is_inbound(cell) and (not ff_cells.has(cell)) and tilemap.get_cellv(cell) == matching_tile
func ff_get_neighbours(tilemap: TileMap, cell: Vector2, matching_tile: int) -> Array:
var neighbours = [Vector2(cell.x, cell.y-1),Vector2(cell.x-1, cell.y),Vector2(cell.x+1, cell.y), Vector2(cell.x, cell.y+1)]
var out = []
for neighbour in neighbours:
# Have we checked this already?
if not ff_is_valid(tilemap, neighbour, matching_tile):
continue
out.push_back(neighbour)
return out
func flood_fill(tilemap: TileMap, pos: Vector2, id: int):
# Reset lists
ff_cells = {}
ff_origin = pos
var current_tile = tilemap.get_cellv(pos)
var queue = ff_get_neighbours(tilemap, pos, current_tile)
place_tile(tilemap, pos, id)
ff_cells[pos] = true
# Depth-first search
while not queue.empty():
var current = queue.pop_front()
# Have we checked this already?
if not ff_is_valid(tilemap, current, current_tile):
continue
var tile_id = tilemap.get_cellv(current)
if tile_id == current_tile:
ff_cells[current] = true
place_tile(tilemap, current, id)
for neighbour in ff_get_neighbours(tilemap, current, current_tile):
queue.push_front(neighbour)
tilemap.update_bitmask_region()
func _set_obj_action(action):
match action:
"add":
current_tool = Tool.OBJ_PLACE
"edit":
current_tool = Tool.OBJ_EDIT
"remove":
current_tool = Tool.OBJ_REMOVE
objects_panel.visible = true
func tile_pressed(button: int, pos: Vector2):
match button:
BUTTON_LEFT:
placing = true
BUTTON_RIGHT:
deleting = true
match current_tool:
Tool.TILE_FREEHAND:
if placing_layer != null:
place_tiles(placing_layer, [pos], get_active_tile())
Tool.OBJ_PLACE:
pass
pressed_pos = pos
func tile_released(button: int, pos: Vector2):
match current_tool:
Tool.TILE_RECT:
if placing_layer != null:
place_rect(pressed_pos, pos, get_active_tile())
Tool.TILE_FILL:
if placing_layer != null:
flood_fill(placing_layer, pos, get_active_tile())
match button:
BUTTON_LEFT:
placing = false
BUTTON_RIGHT:
deleting = false
func tile_mouse_move(_from: Vector2, to: Vector2):
match current_tool:
Tool.TILE_FREEHAND:
if placing_layer != null:
place_tiles(placing_layer, [to], get_active_tile())
func get_active_tile():
if deleting:
return -1
return placing_tile_id

443
Scenes/MapEditor.tscn Normal file
View file

@ -0,0 +1,443 @@
[gd_scene load_steps=28 format=2]
[ext_resource path="res://Graphics/deepspace_mat.tres" type="Material" id=1]
[ext_resource path="res://Scenes/InEditorMap.gd" type="Script" id=2]
[ext_resource path="res://Graphics/tgstation/walls.tres" type="TileSet" id=3]
[ext_resource path="res://Graphics/UI/editor-icons.png" type="Texture" id=4]
[ext_resource path="res://Graphics/tgstation/base.tres" type="TileSet" id=5]
[ext_resource path="res://Graphics/tgstation/floor.tres" type="TileSet" id=6]
[ext_resource path="res://Graphics/tgstation/cables.tres" type="TileSet" id=7]
[ext_resource path="res://Scenes/Rendering/MapTiles.gd" type="Script" id=8]
[ext_resource path="res://Graphics/UI/uifont.tres" type="DynamicFont" id=9]
[ext_resource path="res://Scenes/MapEditor.gd" type="Script" id=10]
[ext_resource path="res://Graphics/UI/grid.png" type="Texture" id=11]
[ext_resource path="res://Graphics/UI/ui_theme.tres" type="Theme" id=12]
[ext_resource path="res://Scenes/Editor/ToolButtonTheme.tres" type="Theme" id=13]
[sub_resource type="StyleBoxFlat" id=1]
content_margin_left = 15.0
content_margin_right = 15.0
content_margin_top = 5.0
content_margin_bottom = 5.0
bg_color = Color( 0.0588235, 0.0627451, 0.105882, 0.784314 )
corner_radius_top_left = 10
corner_radius_top_right = 10
corner_radius_bottom_right = 10
corner_radius_bottom_left = 10
[sub_resource type="StyleBoxFlat" id=2]
content_margin_left = 10.0
content_margin_right = 10.0
bg_color = Color( 0.364706, 0.45098, 0.607843, 0.392157 )
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
[sub_resource type="StyleBoxFlat" id=3]
content_margin_left = 10.0
content_margin_right = 10.0
bg_color = Color( 0.305882, 0.368627, 0.576471, 0.784314 )
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
[sub_resource type="StyleBoxEmpty" id=4]
content_margin_left = 10.0
content_margin_right = 10.0
[sub_resource type="ButtonGroup" id=5]
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 4 )
region = Rect2( 0, 0, 16, 16 )
[sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 4 )
region = Rect2( 16, 0, 16, 16 )
[sub_resource type="ButtonGroup" id=8]
[sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 4 )
region = Rect2( 0, 16, 16, 16 )
[sub_resource type="AtlasTexture" id=10]
atlas = ExtResource( 4 )
region = Rect2( 32, 16, 16, 16 )
[sub_resource type="AtlasTexture" id=11]
atlas = ExtResource( 4 )
region = Rect2( 16, 16, 16, 16 )
[sub_resource type="AtlasTexture" id=12]
atlas = ExtResource( 4 )
region = Rect2( 0, 32, 16, 16 )
[sub_resource type="AtlasTexture" id=13]
atlas = ExtResource( 4 )
region = Rect2( 16, 32, 16, 16 )
[sub_resource type="AtlasTexture" id=14]
atlas = ExtResource( 4 )
region = Rect2( 32, 32, 16, 16 )
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 10 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="background" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 0 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="map" type="Node2D" parent="."]
z_index = -5
z_as_relative = false
script = ExtResource( 2 )
[node name="background" type="Sprite" parent="map"]
material = ExtResource( 1 )
position = Vector2( -2560, -2784 )
texture = ExtResource( 11 )
centered = false
region_enabled = true
region_rect = Rect2( 0, 0, 6400, 6400 )
__meta__ = {
"_edit_lock_": true
}
[node name="grid" type="Sprite" parent="map"]
position = Vector2( -2560, -2784 )
texture = ExtResource( 11 )
centered = false
region_enabled = true
region_rect = Rect2( 0, 0, 6400, 6400 )
__meta__ = {
"_edit_lock_": true
}
[node name="tiles" type="Node2D" parent="map"]
[node name="base" type="TileMap" parent="map/tiles"]
z_index = 1
tile_set = ExtResource( 5 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
[node name="cables" type="TileMap" parent="map/tiles"]
z_index = 2
tile_set = ExtResource( 7 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
[node name="floor" type="TileMap" parent="map/tiles"]
z_index = 3
tile_set = ExtResource( 6 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
[node name="walls" type="TileMap" parent="map/tiles"]
z_index = 4
tile_set = ExtResource( 3 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
script = ExtResource( 8 )
[node name="engines" type="Node2D" parent="map"]
modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="objects" type="Node2D" parent="map"]
z_index = 10
__meta__ = {
"_editor_description_": ""
}
[node name="sockets" type="Node2D" parent="map"]
z_index = 2
z_as_relative = false
[node name="lights" type="Node2D" parent="map"]
modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
z_index = 11
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="pois" type="Node2D" parent="map"]
z_index = 999
[node name="areas" type="Node2D" parent="map"]
[node name="cursor" type="Node2D" parent="map"]
[node name="preview" type="Sprite" parent="map/cursor"]
modulate = Color( 1, 1, 1, 0.666667 )
z_index = 5
centered = false
[node name="menu" type="PanelContainer" parent="."]
margin_left = 5.0
margin_top = 5.0
margin_right = 1275.0
margin_bottom = 43.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="menu"]
margin_left = 526.0
margin_top = 5.0
margin_right = 744.0
margin_bottom = 33.0
size_flags_horizontal = 4
size_flags_vertical = 6
custom_styles/normal = SubResource( 1 )
custom_fonts/font = ExtResource( 9 )
text = "- Untitled (untitled.omd) -"
align = 1
[node name="menubar" type="HBoxContainer" parent="menu"]
margin_left = 4.0
margin_top = 4.0
margin_right = 1266.0
margin_bottom = 34.0
rect_min_size = Vector2( 0, 30 )
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="MapMenu" type="MenuButton" parent="menu/menubar"]
margin_right = 46.0
margin_bottom = 30.0
custom_styles/hover = SubResource( 2 )
custom_styles/pressed = SubResource( 3 )
custom_styles/normal = SubResource( 4 )
custom_fonts/font = ExtResource( 9 )
text = "Map"
flat = false
switch_on_hover = true
[node name="PlayMenu" type="MenuButton" parent="menu/menubar"]
visible = false
margin_left = 50.0
margin_right = 98.0
margin_bottom = 30.0
custom_styles/hover = SubResource( 2 )
custom_styles/pressed = SubResource( 3 )
custom_styles/normal = SubResource( 4 )
custom_fonts/font = ExtResource( 9 )
text = "Play"
flat = false
[node name="tools" type="HBoxContainer" parent="."]
margin_left = 9.0
margin_top = 54.0
margin_right = 35.0
margin_bottom = 140.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="toolsPanel" type="PanelContainer" parent="tools"]
margin_right = 55.0
margin_bottom = 64.0
size_flags_vertical = 0
[node name="tools" type="VBoxContainer" parent="tools/toolsPanel"]
margin_left = 4.0
margin_top = 4.0
margin_right = 51.0
margin_bottom = 60.0
[node name="placeTile" type="ToolButton" parent="tools/toolsPanel/tools"]
margin_right = 47.0
margin_bottom = 26.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 5 )
text = "tile"
icon = SubResource( 6 )
flat = false
align = 0
[node name="placeObject" type="ToolButton" parent="tools/toolsPanel/tools"]
margin_top = 30.0
margin_right = 47.0
margin_bottom = 56.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 5 )
text = "obj"
icon = SubResource( 7 )
flat = false
align = 0
[node name="brushPanel" type="PanelContainer" parent="tools"]
visible = false
margin_left = 59.0
margin_right = 93.0
margin_bottom = 94.0
size_flags_vertical = 0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="brush" type="VBoxContainer" parent="tools/brushPanel"]
margin_left = 4.0
margin_top = 4.0
margin_right = 30.0
margin_bottom = 90.0
[node name="FreeHand" type="ToolButton" parent="tools/brushPanel/brush"]
margin_right = 26.0
margin_bottom = 26.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 8 )
icon = SubResource( 9 )
flat = false
[node name="Rect" type="ToolButton" parent="tools/brushPanel/brush"]
margin_top = 30.0
margin_right = 26.0
margin_bottom = 56.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 8 )
icon = SubResource( 10 )
flat = false
[node name="Fill" type="ToolButton" parent="tools/brushPanel/brush"]
margin_top = 60.0
margin_right = 26.0
margin_bottom = 86.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 8 )
icon = SubResource( 11 )
flat = false
[node name="objPanel" type="PanelContainer" parent="tools"]
visible = false
margin_left = 59.0
margin_right = 93.0
margin_bottom = 94.0
size_flags_vertical = 0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="brush" type="VBoxContainer" parent="tools/objPanel"]
margin_left = 4.0
margin_top = 4.0
margin_right = 30.0
margin_bottom = 90.0
[node name="add" type="ToolButton" parent="tools/objPanel/brush"]
margin_right = 26.0
margin_bottom = 26.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 8 )
icon = SubResource( 12 )
flat = false
[node name="edit" type="ToolButton" parent="tools/objPanel/brush"]
margin_top = 30.0
margin_right = 26.0
margin_bottom = 56.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 8 )
icon = SubResource( 13 )
flat = false
[node name="remove" type="ToolButton" parent="tools/objPanel/brush"]
margin_top = 60.0
margin_right = 26.0
margin_bottom = 86.0
theme = ExtResource( 13 )
toggle_mode = true
group = SubResource( 8 )
icon = SubResource( 14 )
flat = false
[node name="layers" type="MarginContainer" parent="."]
visible = false
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 5.0
margin_top = -90.0
margin_right = -5.0
margin_bottom = -5.44409
size_flags_vertical = 13
__meta__ = {
"_edit_use_anchors_": false
}
[node name="tabs" type="TabContainer" parent="layers"]
margin_right = 1270.0
margin_bottom = 84.0
rect_min_size = Vector2( 0, 80 )
theme = ExtResource( 12 )
tab_align = 0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="objects" type="MarginContainer" parent="."]
visible = false
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 5.0
margin_top = -256.0
margin_right = 239.0
margin_bottom = -5.0
size_flags_vertical = 13
__meta__ = {
"_edit_use_anchors_": false
}
[node name="tabs" type="TabContainer" parent="objects"]
margin_right = 234.0
margin_bottom = 251.0
rect_min_size = Vector2( 0, 80 )
theme = ExtResource( 12 )
tab_align = 0
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="mouse_entered" from="background" to="." method="_toggle_tile_input" binds= [ true ]]
[connection signal="mouse_exited" from="background" to="." method="_toggle_tile_input" binds= [ false ]]
[connection signal="pressed" from="tools/toolsPanel/tools/placeTile" to="." method="_tool_selected" binds= [ "tile" ]]
[connection signal="pressed" from="tools/toolsPanel/tools/placeObject" to="." method="_tool_selected" binds= [ "obj" ]]
[connection signal="pressed" from="tools/brushPanel/brush/FreeHand" to="." method="_set_brush" binds= [ "freehand" ]]
[connection signal="pressed" from="tools/brushPanel/brush/Rect" to="." method="_set_brush" binds= [ "rect" ]]
[connection signal="pressed" from="tools/brushPanel/brush/Fill" to="." method="_set_brush" binds= [ "fill" ]]
[connection signal="pressed" from="tools/objPanel/brush/add" to="." method="_set_obj_action" binds= [ "add" ]]
[connection signal="pressed" from="tools/objPanel/brush/edit" to="." method="_set_obj_action" binds= [ "edit" ]]
[connection signal="pressed" from="tools/objPanel/brush/remove" to="." method="_set_obj_action" binds= [ "remove" ]]

View file

@ -31,7 +31,9 @@ __meta__ = {
"_edit_lock_": true "_edit_lock_": true
} }
[node name="base" type="TileMap" parent="."] [node name="tiles" type="Node2D" parent="."]
[node name="base" type="TileMap" parent="tiles"]
z_index = 1 z_index = 1
z_as_relative = false z_as_relative = false
tile_set = ExtResource( 11 ) tile_set = ExtResource( 11 )
@ -40,7 +42,7 @@ cell_quadrant_size = 32
occluder_light_mask = -2147483647 occluder_light_mask = -2147483647
format = 1 format = 1
[node name="cables" type="TileMap" parent="."] [node name="cables" type="TileMap" parent="tiles"]
z_index = 2 z_index = 2
z_as_relative = false z_as_relative = false
tile_set = ExtResource( 13 ) tile_set = ExtResource( 13 )
@ -49,7 +51,7 @@ cell_quadrant_size = 32
occluder_light_mask = -2147483647 occluder_light_mask = -2147483647
format = 1 format = 1
[node name="floor" type="TileMap" parent="."] [node name="floor" type="TileMap" parent="tiles"]
z_index = 3 z_index = 3
z_as_relative = false z_as_relative = false
tile_set = ExtResource( 9 ) tile_set = ExtResource( 9 )
@ -58,7 +60,7 @@ cell_quadrant_size = 32
occluder_light_mask = -2147483647 occluder_light_mask = -2147483647
format = 1 format = 1
[node name="walls" type="TileMap" parent="."] [node name="walls" type="TileMap" parent="tiles"]
z_index = 4 z_index = 4
z_as_relative = false z_as_relative = false
tile_set = ExtResource( 1 ) tile_set = ExtResource( 1 )
@ -69,7 +71,7 @@ format = 1
script = ExtResource( 3 ) script = ExtResource( 3 )
extended_tilemap_node = NodePath("../1x1") extended_tilemap_node = NodePath("../1x1")
[node name="1x1" type="TileMap" parent="."] [node name="1x1" type="TileMap" parent="tiles"]
z_index = 5 z_index = 5
z_as_relative = false z_as_relative = false
tile_set = ExtResource( 2 ) tile_set = ExtResource( 2 )

File diff suppressed because one or more lines are too long

View file

@ -1,203 +0,0 @@
[gd_scene load_steps=15 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://Graphics/tgstation/cables.tres" type="TileSet" id=4]
[ext_resource path="res://Actors/Meta/POI/POI.tscn" type="PackedScene" id=5]
[ext_resource path="res://Actors/Objects/Computer/Computer.tscn" type="PackedScene" id=6]
[ext_resource path="res://Graphics/space.png" type="Texture" id=7]
[ext_resource path="res://Graphics/tgstation/floor.tres" type="TileSet" id=9]
[ext_resource path="res://Actors/Objects/Engine/Engine.tscn" type="PackedScene" id=10]
[ext_resource path="res://Graphics/tgstation/base.tres" type="TileSet" id=11]
[ext_resource path="res://Actors/Objects/PowerStorage/PowerStorage.tscn" type="PackedScene" id=12]
[ext_resource path="res://Actors/Objects/ElectricSocket/ElectricSocket.tscn" type="PackedScene" id=13]
[sub_resource type="GDScript" id=1]
script/source = "extends GameMap
func _ready():
set_unlit(true)
"
[sub_resource type="CanvasItemMaterial" id=2]
light_mode = 1
[node name="map" type="Node2D"]
z_as_relative = false
script = SubResource( 1 )
[node name="darkness" type="CanvasModulate" parent="."]
visible = false
color = Color( 0, 0, 0, 1 )
[node name="editor" type="Node2D" parent="."]
[node name="deepspace" type="Sprite" parent="."]
material = SubResource( 2 )
texture = ExtResource( 7 )
region_enabled = true
region_rect = Rect2( 0, 0, 10000, 10000 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="base" type="TileMap" parent="."]
z_index = 1
z_as_relative = false
tile_set = ExtResource( 11 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
tile_data = PoolIntArray( 262137, 0, 0, 262138, 0, 0, 262139, 0, 0, 262140, 0, 0, 262141, 0, 0, 262142, 0, 0, 262143, 0, 0, 196608, 0, 0, 196609, 0, 0, 196610, 0, 0, 196611, 0, 0, 196612, 0, 0, 196613, 0, 0, 196614, 0, 0, 196615, 0, 0, 196616, 0, 0, 196617, 0, 0, 196618, 0, 0, 196619, 0, 0, 196620, 0, 0, 196621, 0, 0, 196622, 0, 0, 196623, 0, 0, 196624, 0, 0, 196625, 0, 0, 196626, 0, 0, 196627, 0, 0, 327673, 0, 0, 327674, 0, 0, 327675, 0, 0, 327676, 0, 0, 327677, 0, 0, 327678, 0, 0, 327679, 0, 0, 262144, 0, 0, 262145, 0, 0, 262146, 0, 0, 262147, 0, 0, 262148, 0, 0, 262149, 0, 0, 262150, 0, 0, 262151, 0, 0, 262152, 0, 0, 262153, 0, 0, 262154, 0, 0, 262155, 0, 0, 262156, 0, 0, 262157, 0, 0, 262158, 0, 0, 262159, 0, 0, 262160, 0, 0, 262161, 0, 0, 262162, 0, 0, 262163, 0, 0, 393209, 0, 0, 393210, 0, 0, 393211, 0, 0, 393212, 0, 0, 393213, 0, 0, 393214, 0, 0, 393215, 0, 0, 327680, 0, 0, 327681, 0, 0, 327682, 0, 0, 327683, 0, 0, 327684, 0, 0, 327685, 0, 0, 327686, 0, 0, 327687, 0, 0, 327688, 0, 0, 327689, 0, 0, 327690, 0, 0, 327691, 0, 0, 327692, 0, 0, 327693, 0, 0, 327694, 0, 0, 327695, 0, 0, 327696, 0, 0, 327697, 0, 0, 327698, 0, 0, 327699, 0, 0, 458745, 0, 0, 458746, 0, 0, 458747, 0, 0, 458748, 0, 0, 458749, 0, 0, 458750, 0, 0, 458751, 0, 0, 393216, 0, 0, 393217, 0, 0, 393218, 0, 0, 393219, 0, 0, 393220, 0, 0, 393221, 0, 0, 393222, 0, 0, 393223, 0, 0, 393224, 0, 0, 393225, 0, 0, 393226, 0, 0, 393227, 0, 0, 393228, 0, 0, 393229, 0, 0, 393230, 0, 0, 393231, 0, 0, 393232, 0, 0, 393233, 0, 0, 393234, 0, 0, 393235, 0, 0, 524281, 0, 0, 524282, 0, 0, 524283, 0, 0, 524284, 0, 0, 524285, 0, 0, 524286, 0, 0, 524287, 0, 0, 458752, 0, 0, 458753, 0, 0, 458754, 0, 0, 458755, 0, 0, 458756, 0, 0, 458757, 0, 0, 458758, 0, 0, 458759, 0, 0, 458760, 0, 0, 458761, 0, 0, 458762, 0, 0, 458763, 0, 0, 458764, 0, 0, 458765, 0, 0, 458766, 0, 0, 458767, 0, 0, 458768, 0, 0, 458769, 0, 0, 458770, 0, 0, 458771, 0, 0, 589817, 0, 0, 589818, 0, 0, 589819, 0, 0, 589820, 0, 0, 589821, 0, 0, 589822, 0, 0, 589823, 0, 0, 524288, 0, 0, 524289, 0, 0, 524290, 0, 0, 524291, 0, 0, 524292, 0, 0, 524293, 0, 0, 524294, 0, 0, 524295, 0, 0, 524296, 0, 0, 524297, 0, 0, 524298, 0, 0, 524299, 0, 0, 524300, 0, 0, 524301, 0, 0, 524302, 0, 0, 524303, 0, 0, 524304, 0, 0, 524305, 0, 0, 524306, 0, 0, 524307, 0, 0, 655353, 0, 0, 655354, 0, 0, 655355, 0, 0, 655356, 0, 0, 655357, 0, 0, 655358, 0, 0, 655359, 0, 0, 589824, 0, 0, 589825, 0, 0, 589826, 0, 0, 589827, 0, 0, 589828, 0, 0, 589829, 0, 0, 589830, 0, 0, 589831, 0, 0, 589832, 0, 0, 589833, 0, 0, 589834, 0, 0, 589835, 0, 0, 589836, 0, 0, 589837, 0, 0, 589838, 0, 0, 589839, 0, 0, 589840, 0, 0, 589841, 0, 0, 589842, 0, 0, 589843, 0, 0, 720889, 0, 0, 720890, 0, 0, 720891, 0, 0, 720892, 0, 0, 720893, 0, 0, 720894, 0, 0, 720895, 0, 0, 655360, 0, 0, 655361, 0, 0, 655362, 0, 0, 655363, 0, 0, 655364, 0, 0, 655365, 0, 0, 655366, 0, 0, 655367, 0, 0, 655368, 0, 0, 655369, 0, 0, 655370, 0, 0, 655371, 0, 0, 655372, 0, 0, 655373, 0, 0, 655374, 0, 0, 655375, 0, 0, 655376, 0, 0, 655377, 0, 0, 655378, 0, 0, 655379, 0, 0, 786425, 0, 0, 786426, 0, 0, 786427, 0, 0, 786428, 0, 0, 786429, 0, 0, 786430, 0, 0, 786431, 0, 0, 720896, 0, 0, 720897, 0, 0, 720898, 0, 0, 720899, 0, 0, 720900, 0, 0, 720901, 0, 0, 720902, 0, 0, 720903, 0, 0, 720904, 0, 0, 720905, 0, 0, 720906, 0, 0, 720907, 0, 0, 720908, 0, 0, 720909, 0, 0, 720910, 0, 0, 720911, 0, 0, 720912, 0, 0, 720913, 0, 0, 720914, 0, 0, 720915, 0, 0, 851961, 0, 0, 851962, 0, 0, 851963, 0, 0, 851964, 0, 0, 851965, 0, 0, 851966, 0, 0, 851967, 0, 0, 786432, 0, 0, 786433, 0, 0, 786434, 0, 0, 786435, 0, 0, 786436, 0, 0, 786437, 0, 0, 786438, 0, 0, 786439, 0, 0, 786440, 0, 0, 786441, 0, 0, 786442, 0, 0, 786443, 0, 0, 786444, 0, 0, 786445, 0, 0, 786446, 0, 0, 786447, 0, 0, 786448, 0, 0, 786449, 0, 0, 786450, 0, 0, 786451, 0, 0 )
[node name="cables" type="TileMap" parent="."]
z_index = 2
z_as_relative = false
tile_set = ExtResource( 4 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
tile_data = PoolIntArray( 393212, 0, 131072, 393213, 0, 65536, 393214, 0, 65536, 393215, 0, 65536, 327680, 0, 65536, 327681, 0, 65536, 327682, 0, 65536, 327683, 0, 65536, 327684, 0, 262144 )
[node name="floor" type="TileMap" parent="."]
z_index = 3
z_as_relative = false
tile_set = ExtResource( 9 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
[node name="walls" type="TileMap" parent="."]
z_index = 4
z_as_relative = false
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32
occluder_light_mask = -2147483647
format = 1
tile_data = PoolIntArray( 196601, 3, 0, 196602, 3, 0, 196603, 3, 0, 196604, 3, 0, 196605, 3, 0, 196606, 3, 0, 196607, 3, 0, 131072, 3, 0, 131073, 3, 0, 131074, 3, 0, 131075, 3, 0, 131076, 3, 0, 131077, 3, 0, 131078, 3, 0, 131079, 3, 0, 131080, 3, 0, 131081, 3, 0, 131082, 3, 0, 131083, 3, 0, 131084, 3, 0, 131085, 3, 0, 131086, 3, 0, 131087, 3, 0, 131088, 3, 0, 131089, 3, 0, 131090, 3, 0, 131091, 3, 0, 196628, 3, 0, 262164, 3, 0, 327700, 3, 0, 393236, 3, 0, 458772, 3, 0, 524308, 3, 0, 589844, 3, 0, 655380, 3, 0, 720916, 3, 0, 786452, 3, 0, 917497, 3, 0, 917498, 3, 0, 917499, 3, 0, 917500, 3, 0, 917501, 3, 0, 917502, 3, 0, 917503, 3, 0, 851968, 3, 0, 851969, 3, 0, 851970, 3, 0, 851971, 3, 0, 851972, 3, 0, 851973, 3, 0, 851974, 3, 0, 851975, 3, 0, 851976, 3, 0, 851977, 3, 0, 851978, 3, 0, 851979, 3, 0, 851980, 3, 0, 851981, 3, 0, 851982, 3, 0, 851983, 3, 0, 851984, 3, 0, 851985, 3, 0, 851986, 3, 0, 851987, 3, 0 )
script = ExtResource( 3 )
extended_tilemap_node = NodePath("../1x1")
[node name="1x1" type="TileMap" parent="."]
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 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="Engine" parent="engines" instance=ExtResource( 10 )]
position = Vector2( -320, 321 )
direction = 0
[node name="Engine2" parent="engines" instance=ExtResource( 10 )]
position = Vector2( -320, 208 )
direction = 0
[node name="Engine3" parent="engines" instance=ExtResource( 10 )]
position = Vector2( -320, 96 )
direction = 0
[node name="objects" type="Node2D" parent="."]
z_index = 10
__meta__ = {
"_editor_description_": ""
}
[node name="Computer" parent="objects" instance=ExtResource( 6 )]
position = Vector2( -64, 128 )
[node name="Computer2" parent="objects" instance=ExtResource( 6 )]
position = Vector2( -32, 128 )
computer_type = 1
[node name="Computer3" parent="objects" instance=ExtResource( 6 )]
position = Vector2( 0, 128 )
computer_type = 2
[node name="Computer4" parent="objects" instance=ExtResource( 6 )]
position = Vector2( 32, 128 )
computer_type = 3
[node name="Computer5" parent="objects" instance=ExtResource( 6 )]
position = Vector2( -96, 128 )
computer_type = 4
[node name="Computer6" parent="objects" instance=ExtResource( 6 )]
position = Vector2( -128, 128 )
computer_type = 5
[node name="SMES2" parent="objects" instance=ExtResource( 12 )]
position = Vector2( 128, 128 )
[node name="Computer7" parent="objects" instance=ExtResource( 6 )]
position = Vector2( 64, 128 )
computer_type = 6
[node name="sockets" type="Node2D" parent="."]
z_index = 2
z_as_relative = false
[node name="ElectricSocket4" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( -128, 160 )
connectionPaths = [ NodePath("../../objects/Computer6") ]
flow = 1
[node name="ElectricSocket5" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( -96, 160 )
connectionPaths = [ NodePath("../../objects/Computer5") ]
flow = 1
[node name="ElectricSocket6" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( -64, 160 )
connectionPaths = [ NodePath("../../objects/Computer") ]
flow = 1
[node name="ElectricSocket7" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( -32, 160 )
connectionPaths = [ NodePath("../../objects/Computer2") ]
flow = 1
[node name="ElectricSocket8" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( 0, 160 )
connectionPaths = [ NodePath("../../objects/Computer3") ]
flow = 1
[node name="ElectricSocket9" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( 32, 160 )
connectionPaths = [ NodePath("../../objects/Computer4") ]
flow = 1
[node name="ElectricSocket10" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( 64, 160 )
connectionPaths = [ NodePath("../../objects/Computer7") ]
flow = 1
[node name="ElectricSocket3" parent="sockets" instance=ExtResource( 13 )]
position = Vector2( 128, 160 )
connectionPaths = [ NodePath("../../objects/SMES2") ]
[node name="lights" type="Node2D" parent="."]
modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
__meta__ = {
"_edit_group_": true,
"_edit_lock_": true
}
[node name="pois" type="Node2D" parent="."]
z_index = 999
[node name="SpawnpointPlayer" parent="pois" instance=ExtResource( 5 )]
position = Vector2( 80, 272 )

View file

@ -2,20 +2,20 @@ extends Control
const REFRESH_SERVER_DELAY = 5.0 const REFRESH_SERVER_DELAY = 5.0
export var scale = 4 setget set_scale export var scale := 4.0 setget set_scale
export var upThreshold = 1.0/59.0 export var upThreshold := 1.0/59.0
export var downThreshold = 1.0/30.0 export var downThreshold := 1.0/30.0
export var delay = 1.0 export var delay := 1.0
export var refresh_server_remaining = REFRESH_SERVER_DELAY export var refresh_server_remaining := REFRESH_SERVER_DELAY
onready var viewport = $Viewport onready var viewport := $Viewport
onready var background = $Background onready var background := $Background
onready var netgame = $"/root/Multiplayer" onready var netgame := $"/root/Multiplayer"
onready var server_list = $Popup/MarginContainer/VBoxContainer/ItemList onready var server_list := $Popup/MarginContainer/VBoxContainer/ItemList
onready var name_field = $CenterContainer/PanelContainer/HBoxContainer/HBoxContainer/NameField onready var name_field := $CenterContainer/PanelContainer/HBoxContainer/HBoxContainer/NameField
var servers = [] var servers := []
func _ready() -> void: func _ready() -> void:
name_field.text = netgame.player_name name_field.text = netgame.player_name

View file

@ -2,48 +2,22 @@ extends TileMap
class_name MapTiles class_name MapTiles
var transparentImage = preload("res://Graphics/transparent.png") var transparentImage := preload("res://Graphics/transparent.png")
export(NodePath) var extended_tilemap_node export(NodePath) var extended_tilemap_node
export var occluders = ["Wall"] export var occluders := ["Wall"]
export var shadow_intensity = 0.2 export var shadow_intensity := 0.2
onready var extended_tilemap = get_node(extended_tilemap_node) as TileMap
func run_conversions(): func run_conversions():
# Make occluders # Make occluders
make_occluders() make_occluders()
# Convert 2x2 tiles to 1x1 if possible
convert_extended()
func convert_extended():
var extended = extended_tilemap.tile_set
for id in tile_set.get_tiles_ids():
var name = tile_set.tile_get_name(id)
var extended_id = extended.find_tile_by_name(name)
if extended_id < 0:
# Not found, skip it
continue
# Find all uses of this tile
for cell in get_used_cells_by_id(id):
var x = cell.x * 2
var y = cell.y * 2
extended_tilemap.set_cell(x, y, extended_id)
extended_tilemap.set_cell(x+1, y, extended_id)
extended_tilemap.set_cell(x, y+1, extended_id)
extended_tilemap.set_cell(x+1, y+1, extended_id)
tile_set.tile_set_texture(id, transparentImage)
extended_tilemap.update_bitmask_region()
extended_tilemap.update_dirty_quadrants()
func make_occluders(): func make_occluders():
var occluder_ids = [] var occluder_ids := []
for occluder_name in occluders: for occluder_name in occluders:
var id = tile_set.find_tile_by_name(occluder_name) var id := tile_set.find_tile_by_name(occluder_name)
if id >= 0: if id >= 0:
occluder_ids.push_back(id) occluder_ids.push_back(id)
for id in tile_set.get_tiles_ids(): for id in tile_set.get_tiles_ids():
@ -53,7 +27,7 @@ func make_occluders():
# Find all uses of this tile # Find all uses of this tile
for cell in get_used_cells_by_id(id): for cell in get_used_cells_by_id(id):
# Check sides # Check sides
var occluder = Occluder.new() var occluder := Occluder.new()
occluder.ignore_sides = [ occluder.ignore_sides = [
occluder_ids.find(get_cell(cell.x, cell.y-1)) >= 0, # Top occluder_ids.find(get_cell(cell.x, cell.y-1)) >= 0, # Top
occluder_ids.find(get_cell(cell.x+1, cell.y)) >= 0, # Right occluder_ids.find(get_cell(cell.x+1, cell.y)) >= 0, # Right
@ -63,7 +37,6 @@ func make_occluders():
occluder.transform.origin = map_to_world(cell) occluder.transform.origin = map_to_world(cell)
add_child(occluder) add_child(occluder)
func set_occluder_origin(origin): func set_occluder_origin(origin):
for child in get_children(): for child in get_children():
if child is Occluder: if child is Occluder:

View file

@ -11,36 +11,36 @@ enum PopupName {
EnergyUsage EnergyUsage
} }
onready var logs = $Logs onready var logs := $Logs
onready var inspect_box = $InspectBox as RichTextLabel onready var inspect_box := $InspectBox as RichTextLabel
onready var item_slots_container = $ItemSlots onready var item_slots_container := $ItemSlots
onready var map_popup = $MapPopup onready var map_popup := $MapPopup
onready var sever_info_popup = $ServerInfoPopup onready var sever_info_popup := $ServerInfoPopup
onready var scene = $"/root/scene" onready var scene := $"/root/scene"
onready var netgame = $"/root/Multiplayer" onready var netgame := $"/root/Multiplayer"
const ItemBox = preload("res://Scenes/UI/Items/ItemBox.tscn") const ItemBox := preload("res://Scenes/UI/Items/ItemBox.tscn")
var left_selected = null var left_selected: Node = null
var right_selected = null var right_selected: Node = null
const WHISPER_RADIUS = 32*3 const WHISPER_RADIUS := 32*3
const CHAT_RADIUS = 32*10 const CHAT_RADIUS := 32*10
const SHOUT_RADIUS = 32*14 const SHOUT_RADIUS := 32*14
var inspect_mode = false var inspect_mode := false
var current_inspecting = null var current_inspecting = null
func _ready() -> void: func _ready() -> void:
# Add options to menu buttons # 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.connect("id_pressed", self, "_server_option_chosen")
serverMenu.add_item("Server info", ServerMenuItem.ServerInfo) serverMenu.add_item("Server info", ServerMenuItem.ServerInfo)
# Create item slots # Create item slots
for slot_id in range(4): 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 # By default, slot 2/3 are L/R, and 2 is selected
match slot_id: match slot_id:
@ -60,7 +60,7 @@ func _ready() -> void:
func _physics_process(_delta: float) -> void: func _physics_process(_delta: float) -> void:
if inspect_mode: 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) var results = scene.physics.intersect_point(mouse_pos, 1, [], 2)
if results.size() > 0: if results.size() > 0:
var obj = results[0].collider var obj = results[0].collider
@ -136,7 +136,7 @@ func _input(event: InputEvent) -> void:
elif event.is_action_pressed("swap_hands"): elif event.is_action_pressed("swap_hands"):
swap_hands() swap_hands()
elif event is InputEventMouseMotion: elif event is InputEventMouseMotion:
var mousemotion = event as InputEventMouseMotion var mousemotion := event as InputEventMouseMotion
if inspect_mode: if inspect_mode:
inspect_box.rect_global_position = mousemotion.position + inspect_offset 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 return map_popup.visible or sever_info_popup.visible
func select_next_box(direction: int, right_hand: bool) -> void: 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: if right_hand:
box = right_selected box = right_selected
var parent = box.get_parent() var parent := box.get_parent()
var child_count = parent.get_child_count() var child_count := parent.get_child_count()
var index = box.get_index() var index := box.get_index()
index += direction index += direction
if index < 0: if index < 0:
index = child_count + index index = child_count + index

View file

@ -11,14 +11,14 @@ enum CurrentHand {
Right Right
} }
var hovering = false var hovering := false
export var selected = false setget set_selected export var selected := false setget set_selected
export(CurrentHand) var current_hand = CurrentHand.None setget set_hand export(CurrentHand) var current_hand := CurrentHand.None setget set_hand
const LEFT_Y_OFFSET = 0 const LEFT_Y_OFFSET := 0
const RIGHT_Y_OFFSET = 10 const RIGHT_Y_OFFSET := 10
onready var hand_icon = $HandIcon onready var hand_icon := $HandIcon
func _ready(): func _ready():
hand_icon.texture = hand_icon.texture.duplicate() hand_icon.texture = hand_icon.texture.duplicate()
@ -50,7 +50,7 @@ func set_hand(hand):
func _gui_input(event): func _gui_input(event):
if event is InputEventMouseButton: if event is InputEventMouseButton:
var mouse_event = event as InputEventMouseButton var mouse_event := event as InputEventMouseButton
if mouse_event.pressed: if mouse_event.pressed:
if mouse_event.button_index == BUTTON_LEFT: if mouse_event.button_index == BUTTON_LEFT:
if current_hand != CurrentHand.Left: if current_hand != CurrentHand.Left:

View file

@ -35,14 +35,15 @@ custom_constants/separation = 10
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
margin_right = 528.0 margin_right = 528.0
margin_bottom = 18.0 margin_bottom = 24.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"] [node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_top = 3.0
margin_right = 104.0 margin_right = 104.0
margin_bottom = 18.0 margin_bottom = 21.0
text = "S01\\AR SYSTEM" text = "S01\\AR SYSTEM"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
@ -51,7 +52,7 @@ __meta__ = {
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 108.0 margin_left = 108.0
margin_right = 528.0 margin_right = 528.0
margin_bottom = 18.0 margin_bottom = 24.0
size_flags_horizontal = 3 size_flags_horizontal = 3
alignment = 2 alignment = 2
__meta__ = { __meta__ = {
@ -59,9 +60,10 @@ __meta__ = {
} }
[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"] [node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
margin_left = 330.0 margin_left = 210.0
margin_right = 368.0 margin_top = 3.0
margin_bottom = 18.0 margin_right = 248.0
margin_bottom = 21.0
text = "SPD: " text = "SPD: "
align = 2 align = 2
__meta__ = { __meta__ = {
@ -69,9 +71,10 @@ __meta__ = {
} }
[node name="CurrentSpeed" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"] [node name="CurrentSpeed" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
margin_left = 372.0 margin_left = 252.0
margin_right = 372.0 margin_top = 3.0
margin_bottom = 18.0 margin_right = 252.0
margin_bottom = 21.0
custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 ) custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
align = 2 align = 2
__meta__ = { __meta__ = {
@ -79,9 +82,10 @@ __meta__ = {
} }
[node name="Label3" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"] [node name="Label3" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
margin_left = 376.0 margin_left = 256.0
margin_right = 416.0 margin_top = 3.0
margin_bottom = 18.0 margin_right = 296.0
margin_bottom = 21.0
text = "ANGL:" text = "ANGL:"
align = 2 align = 2
__meta__ = { __meta__ = {
@ -89,17 +93,27 @@ __meta__ = {
} }
[node name="CurrentAngle" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"] [node name="CurrentAngle" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
margin_left = 420.0 margin_left = 300.0
margin_right = 420.0 margin_top = 3.0
margin_bottom = 18.0 margin_right = 300.0
margin_bottom = 21.0
custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 ) custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
align = 2 align = 2
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Button" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
margin_left = 304.0
margin_right = 420.0
margin_bottom = 24.0
text = "Set destination"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Map" type="Control" parent="MarginContainer/VBoxContainer"] [node name="Map" type="Control" parent="MarginContainer/VBoxContainer"]
margin_top = 28.0 margin_top = 34.0
margin_right = 528.0 margin_right = 528.0
margin_bottom = 446.0 margin_bottom = 446.0
rect_clip_content = true rect_clip_content = true
@ -110,3 +124,5 @@ background = ExtResource( 2 )
font = ExtResource( 3 ) font = ExtResource( 3 )
[connection signal="about_to_show" from="." to="MarginContainer/VBoxContainer/Map" method="_reset_position"] [connection signal="about_to_show" from="." to="MarginContainer/VBoxContainer/Map" method="_reset_position"]
[connection signal="popup_hide" from="." to="MarginContainer/VBoxContainer/Map" method="_on_hide"] [connection signal="popup_hide" from="." to="MarginContainer/VBoxContainer/Map" method="_on_hide"]
[connection signal="mouse_entered" from="MarginContainer/VBoxContainer/Map" to="MarginContainer/VBoxContainer/Map" method="_mouse_status" binds= [ true ]]
[connection signal="mouse_exited" from="MarginContainer/VBoxContainer/Map" to="MarginContainer/VBoxContainer/Map" method="_mouse_status" binds= [ false ]]

View file

@ -1,35 +1,36 @@
extends Control extends Control
export var cell_size = 150 export var cell_size := 150
export var bgzoom = 50 export var bgzoom := 50
const BORDER_WIDTH = 4 const BORDER_WIDTH := 4
const BORDER_LENGTH = 30 const BORDER_LENGTH := 30
const RADAR_EFFECT_DELAY = 1 const RADAR_EFFECT_DELAY := 1
const HALF_BORDER = BORDER_LENGTH/2 const HALF_BORDER := BORDER_LENGTH/2
const MIN_ZOOM = 30 const MIN_ZOOM := 40
const ZOOM_STEP = 10 const ZOOM_STEP := 10
const MAX_ZOOM = 400 const MAX_ZOOM := 400
export(Texture) var background export(Texture) var background
export(Font) var font export(Font) var font
var dragging = false var inside := false
var origin = Vector2.ZERO var dragging := false
var last_origin = origin var origin := Vector2.ZERO
var last_mouse_pos = Vector2.ZERO var last_origin := origin
var set_position = true var last_mouse_pos := Vector2.ZERO
var radar_next_remaining = RADAR_EFFECT_DELAY var set_position := true
var offset = Vector2.ZERO var radar_next_remaining := RADAR_EFFECT_DELAY
var text_two_lines = false var offset := Vector2.ZERO
var text_two_lines := false
onready var scene = $"/root/scene" onready var scene := $"/root/scene"
onready var speed_text = $"../HBoxContainer/HBoxContainer/CurrentSpeed" onready var speed_text := $"../HBoxContainer/HBoxContainer/CurrentSpeed"
onready var dir_text = $"../HBoxContainer/HBoxContainer/CurrentAngle" onready var dir_text := $"../HBoxContainer/HBoxContainer/CurrentAngle"
onready var popup = $"../../.." onready var popup := $"../../.."
var last_pos = [] var last_pos := []
func _ready(): func _ready():
font = font.duplicate() font = font.duplicate()
@ -37,7 +38,7 @@ func _ready():
func _physics_process(delta): func _physics_process(delta):
radar_next_remaining -= delta radar_next_remaining -= delta
if radar_next_remaining < 0: 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) last_pos.append(current_position)
if last_pos.size() > 20: if last_pos.size() > 20:
last_pos.pop_front() last_pos.pop_front()
@ -49,17 +50,17 @@ func _physics_process(delta):
update() update()
func _draw(): func _draw():
var win_size = get_global_rect().size 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 current_position: Vector2 = (scene.world.map.current_ship_position + scene.world.map.current_ship_subpos) * cell_size
if set_position: if set_position:
origin = current_position - win_size/2 origin = current_position - win_size/2
last_origin = origin last_origin = origin
if win_size.x > 0: if win_size.x > 0:
set_position = false set_position = false
var cols = int(ceil(win_size.x/cell_size)) var cols := int(ceil(win_size.x/cell_size))
var rows = int(ceil(win_size.y/cell_size)) var rows := int(ceil(win_size.y/cell_size))
var xoffset = float(int(origin.x) % cell_size) var xoffset := float(int(origin.x) % cell_size)
var yoffset = float(int(origin.y) % 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)) 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): 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) draw_line(Vector2(i * cell_size-xoffset, 0), Vector2(i * cell_size-xoffset, win_size.y), Color.white * 0.5)
@ -67,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) 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 x in range(-1, cols+1):
for y in range(-1, rows+1): for y in range(-1, rows+1):
var real_x = x + int(origin.x/cell_size) var real_x := x + int(origin.x/cell_size)
var real_y = y + int(origin.y/cell_size) var real_y := y + int(origin.y/cell_size)
var sector = Coordinates.as_string_parts(Vector2(real_x, real_y)) var sector = Coordinates.as_string_parts(Vector2(real_x, real_y))
if text_two_lines: 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)) draw_string(font, Vector2(x * cell_size + 6 - xoffset, y * cell_size + 20 - yoffset), sector[0], Color(1,1,1,0.5))
@ -76,9 +77,9 @@ func _draw():
else: 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)) 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): 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)) draw_circle(last_pos[pos_index] * cell_size - origin, 2, Color(1, 0, 0, pos_index*1.0/point_count))
@ -89,7 +90,7 @@ func _draw():
var current_target = scene.world.map.current_ship_target var current_target = scene.world.map.current_ship_target
if current_target != null: 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_target(viewport, current_target_adj, Color.green)
draw_line(current_position - origin, current_target_adj - origin, Color.darkcyan) draw_line(current_position - origin, current_target_adj - origin, Color.darkcyan)
@ -99,8 +100,8 @@ func draw_target(viewport: Rect2, position: Vector2, color: Color):
draw_circle(position - viewport.position, 5, color) draw_circle(position - viewport.position, 5, color)
else: else:
# Draw line pointing to target # Draw line pointing to target
var relative_pos = position - viewport.position 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 clamped := Vector2(clamp(relative_pos.x, 0, viewport.size.x), clamp(relative_pos.y, 0, viewport.size.y))
if relative_pos.x < 0: if relative_pos.x < 0:
draw_line(Vector2(0, clamped.y-HALF_BORDER), Vector2(0, clamped.y+HALF_BORDER), color, BORDER_WIDTH) draw_line(Vector2(0, clamped.y-HALF_BORDER), Vector2(0, clamped.y+HALF_BORDER), color, BORDER_WIDTH)
elif relative_pos.x > viewport.size.x: elif relative_pos.x > viewport.size.x:
@ -111,7 +112,7 @@ func draw_target(viewport: Rect2, position: Vector2, color: Color):
draw_line(Vector2(clamped.x-HALF_BORDER, viewport.size.y), Vector2(clamped.x+HALF_BORDER, viewport.size.y), color, BORDER_WIDTH) draw_line(Vector2(clamped.x-HALF_BORDER, viewport.size.y), Vector2(clamped.x+HALF_BORDER, viewport.size.y), color, BORDER_WIDTH)
func _input(event): func _input(event):
if not visible: if not visible or not inside:
return return
if event.is_action_pressed("ui_zoomin"): if event.is_action_pressed("ui_zoomin"):
if cell_size < MAX_ZOOM: if cell_size < MAX_ZOOM:
@ -147,7 +148,7 @@ func update_font():
font.size = 14 font.size = 14
func _recalc_offset(mult: float): 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 origin = ((origin + mouse) / cell_size * (cell_size + mult)) - mouse
func _reset_position(): func _reset_position():
@ -155,3 +156,6 @@ func _reset_position():
func _on_hide(): func _on_hide():
popup.visible = false popup.visible = false
func _mouse_status(entered):
inside = entered

View file

@ -4,9 +4,9 @@ class_name GameWorld
enum Map { RUNTIME, ODYSSEY, EMPTY } 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 var player = null
onready var scene_manager = $"/root/SceneManager" onready var scene_manager = $"/root/SceneManager"
@ -22,10 +22,10 @@ func load_map(map_name):
add_child(map) add_child(map)
func spawn_player(peer: int, is_current_user: bool): func spawn_player(peer: int, is_current_user: bool):
var playerNode = playerRes.instance() var playerNode := playerRes.instance()
playerNode.set_network_master(peer, true) playerNode.set_network_master(peer, true)
playerNode.is_controlled = is_current_user 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: if spawnpoints.size() > 0:
playerNode.transform.origin = (spawnpoints[0] as Node2D).transform.origin playerNode.transform.origin = (spawnpoints[0] as Node2D).transform.origin
else: else:

View file

@ -1,7 +1,9 @@
extends Node extends Node
class_name GameSystems
func serialize() -> Dictionary: func serialize() -> Dictionary:
var systems = {} var systems := {}
for child in get_children(): for child in get_children():
systems[child.name] = { systems[child.name] = {
"script": child.script.resource_path, "script": child.script.resource_path,
@ -11,7 +13,7 @@ func serialize() -> Dictionary:
func deserialize(data: Dictionary) -> void: func deserialize(data: Dictionary) -> void:
for system_name in data: 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() var system_node = load(system_data.script).new()
system_node.name = system_name system_node.name = system_name
add_child(system_node, true) add_child(system_node, true)

View file

@ -1,7 +0,0 @@
[plugin]
name="PowerNetworkHelper"
description="Helper tools for connecting devices to power networks"
author="Hamcha"
version="0.1"
script="plugin.gd"

View file

@ -1,13 +0,0 @@
tool
extends EditorPlugin
var dock
func _enter_tree():
dock = preload("res://addons/pnhelper/pngui.tscn").instance()
dock.api = self
add_control_to_dock(DOCK_SLOT_RIGHT_BL, dock)
func _exit_tree():
remove_control_from_docks(dock)
dock.free()

View file

@ -1,57 +0,0 @@
tool
extends Control
var socketTemplate = preload("res://Actors/Objects/ElectricSocket/ElectricSocket.tscn")
var api : EditorPlugin
onready var socket_types = $Commands/MakeSocket/Type
func _ready():
# Add make_socket options
socket_types.add_item("SNK", 0)
socket_types.add_item("SRC", 1)
socket_types.add_item("BID", 2)
func _make_socket(direction: String) -> void:
var socket_dir = null
var socket_type = null
var offset = Vector2.ZERO
match direction:
"up":
socket_dir = ElectricSocket.Direction.DOWN
offset.y = -32
"left":
socket_dir = ElectricSocket.Direction.RIGHT
offset.x = -32
"down":
socket_dir = ElectricSocket.Direction.UP
offset.y = 32
"right":
socket_dir = ElectricSocket.Direction.LEFT
offset.x = 32
match socket_types.get_selected_id():
0:
socket_type = ElectricSocket.Flow.SINK
1:
socket_type = ElectricSocket.Flow.SOURCE
2:
socket_type = ElectricSocket.Flow.BIDIRECTIONAL
var map = api.get_editor_interface().get_edited_scene_root()
var sockets = map.get_node("sockets")
var nodes = api.get_editor_interface().get_selection().get_selected_nodes()
for node in nodes:
var socket = socketTemplate.instance()
sockets.add_child(socket)
socket.direction = socket_dir
socket.flow = socket_type
socket.owner = map
socket.global_position = node.global_position + offset
socket.connectionPaths = [socket.get_path_to(node)]
func _area_debug_modified(button_pressed):
var map = api.get_editor_interface().get_edited_scene_root() as GameMap
map.debug_areas = button_pressed
for area in map.get_node("areas").get_children():
area.update()

View file

@ -1,73 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/pnhelper/pngui.gd" type="Script" id=1]
[node name="Mapping tools" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Commands" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MakeSocket" type="HBoxContainer" parent="Commands"]
margin_right = 1280.0
margin_bottom = 20.0
[node name="Label" type="Label" parent="Commands/MakeSocket"]
margin_top = 3.0
margin_right = 84.0
margin_bottom = 17.0
text = "Make socket "
[node name="Type" type="OptionButton" parent="Commands/MakeSocket"]
margin_left = 88.0
margin_right = 142.0
margin_bottom = 20.0
text = "SNK"
items = [ "SNK", null, false, 0, null, "SRC", null, false, 1, null, "BID", null, false, 2, null ]
selected = 0
[node name="Left" type="Button" parent="Commands/MakeSocket"]
margin_left = 146.0
margin_right = 166.0
margin_bottom = 20.0
text = "<"
[node name="Up" type="Button" parent="Commands/MakeSocket"]
margin_left = 170.0
margin_right = 189.0
margin_bottom = 20.0
text = "^"
[node name="Down" type="Button" parent="Commands/MakeSocket"]
margin_left = 193.0
margin_right = 212.0
margin_bottom = 20.0
text = "v"
[node name="Right" type="Button" parent="Commands/MakeSocket"]
margin_left = 216.0
margin_right = 236.0
margin_bottom = 20.0
text = ">"
[node name="DebugAreas" type="CheckBox" parent="Commands"]
margin_top = 24.0
margin_right = 1280.0
margin_bottom = 48.0
text = "Show areas"
[connection signal="pressed" from="Commands/MakeSocket/Left" to="." method="_make_socket" binds= [ "left" ]]
[connection signal="pressed" from="Commands/MakeSocket/Up" to="." method="_make_socket" binds= [ "up" ]]
[connection signal="pressed" from="Commands/MakeSocket/Down" to="." method="_make_socket" binds= [ "down" ]]
[connection signal="pressed" from="Commands/MakeSocket/Right" to="." method="_make_socket" binds= [ "right" ]]
[connection signal="toggled" from="Commands/DebugAreas" to="." method="_area_debug_modified"]

View file

@ -64,6 +64,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://Actors/Objects/Scanner/Scanner.gd" "path": "res://Actors/Objects/Scanner/Scanner.gd"
}, { }, {
"base": "Node",
"class": "GameSystems",
"language": "GDScript",
"path": "res://Scenes/systems.gd"
}, {
"base": "Control", "base": "Control",
"class": "GameUI", "class": "GameUI",
"language": "GDScript", "language": "GDScript",
@ -119,6 +124,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://Classes/ResourceQueue.gd" "path": "res://Classes/ResourceQueue.gd"
}, { }, {
"base": "ScrollContainer",
"class": "TileTab",
"language": "GDScript",
"path": "res://Scenes/Editor/TileTab.gd"
}, {
"base": "Reference", "base": "Reference",
"class": "UICommand", "class": "UICommand",
"language": "GDScript", "language": "GDScript",
@ -141,6 +151,7 @@ _global_script_class_icons={
"GameObjectLightbulb": "", "GameObjectLightbulb": "",
"GameObjectPowerStorage": "", "GameObjectPowerStorage": "",
"GameObjectScanner": "", "GameObjectScanner": "",
"GameSystems": "",
"GameUI": "", "GameUI": "",
"GameWorld": "", "GameWorld": "",
"MapTiles": "", "MapTiles": "",
@ -152,6 +163,7 @@ _global_script_class_icons={
"ProbeArea": "", "ProbeArea": "",
"ProbeElectric": "", "ProbeElectric": "",
"ResourceQueue": "", "ResourceQueue": "",
"TileTab": "",
"UICommand": "", "UICommand": "",
"UIItemBox": "" "UIItemBox": ""
} }
@ -177,7 +189,7 @@ window/size/height=800
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "pnhelper" ) enabled=PoolStringArray( )
[gui] [gui]