Engines now suck energy juice. Also you can go places. Also readme and stuff
This commit is contained in:
parent
5ca3c191cd
commit
5316affe0e
24 changed files with 427 additions and 109 deletions
|
@ -95,6 +95,9 @@ func _force_close_ui():
|
|||
if open:
|
||||
open = false
|
||||
$UIAnimation.play("fadeout")
|
||||
match computer_type:
|
||||
ComputerType.ShipCommand:
|
||||
$Control/ControlComp.force_close()
|
||||
|
||||
func _power_status_changed(powered: bool) -> void:
|
||||
activationRange.visible = powered
|
||||
|
|
|
@ -165,10 +165,10 @@ z_index = 999
|
|||
|
||||
[node name="ControlComp" parent="Control" instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
margin_left = -42.0
|
||||
margin_top = -58.0
|
||||
margin_right = 193.0
|
||||
margin_bottom = 47.0
|
||||
margin_left = -47.0
|
||||
margin_top = -81.0
|
||||
margin_right = 208.0
|
||||
margin_bottom = 66.0
|
||||
rect_scale = Vector2( 0.5, 0.5 )
|
||||
|
||||
[node name="ActivationRange" type="Area2D" parent="."]
|
||||
|
|
|
@ -3,13 +3,26 @@ extends Control
|
|||
onready var scene = $"/root/scene" as GameInstance
|
||||
|
||||
func _physics_process(_delta):
|
||||
var speed_str = str(round(scene.world.map.current_ship_speed)) + " u/s"
|
||||
$Container/VelocityBox/HBoxContainer3/CurrentSpeed.text = speed_str
|
||||
var speed_str = str(round(scene.world.map.current_ship_speed * 10000)) + " u/s"
|
||||
$Margin/Container/VelocityBox/HBoxContainer3/CurrentSpeed.text = speed_str
|
||||
var dir_str = str(round(rad2deg(scene.world.map.current_ship_direction))) + " deg"
|
||||
$Container/VelocityBox/HBoxContainer2/CurrentDirection.text = dir_str
|
||||
$Margin/Container/VelocityBox/HBoxContainer2/CurrentDirection.text = dir_str
|
||||
var current_position_str = Coordinates.as_string(scene.world.map.current_ship_position, true)
|
||||
$Margin/Container/VelocityBox/HBoxContainer4/CurrentPosition.text = current_position_str
|
||||
var current_target_str = scene.world.map.current_ship_target
|
||||
if current_target_str == null:
|
||||
$Margin/Container/VelocityBox/HBoxContainer/CurrentTarget.text = "None"
|
||||
else:
|
||||
$Margin/Container/VelocityBox/HBoxContainer/CurrentTarget.text = Coordinates.as_string(current_target_str, true)
|
||||
|
||||
func _ship_velocity_changed(value):
|
||||
scene.process_command(UICommand.new(UICommand.CommandType.SetShipSpeed, [value]))
|
||||
scene.rpc("process_command", UICommand.new(UICommand.CommandType.SetShipSpeed, [value]))
|
||||
|
||||
func _ship_direction_changed(value):
|
||||
scene.process_command(UICommand.new(UICommand.CommandType.SetShipDirection, [deg2rad(value)]))
|
||||
scene.rpc("process_command", UICommand.new(UICommand.CommandType.SetShipDirection, [deg2rad(value)]))
|
||||
|
||||
func _map_button_pressed():
|
||||
scene.ui.open_map_popup()
|
||||
|
||||
func force_close():
|
||||
scene.ui.close_map_popup()
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
[node name="ControlComp" type="Control"]
|
||||
material = ExtResource( 4 )
|
||||
margin_left = -121.0
|
||||
margin_left = -157.0
|
||||
margin_top = -150.0
|
||||
margin_right = 121.0
|
||||
margin_right = 156.0
|
||||
margin_bottom = -20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
|
@ -48,25 +50,37 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Container" type="VBoxContainer" parent="."]
|
||||
material = ExtResource( 4 )
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -10.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 20
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VelocityBox" type="VBoxContainer" parent="Container"]
|
||||
[node name="Container" type="VBoxContainer" parent="Margin"]
|
||||
material = ExtResource( 4 )
|
||||
margin_right = 222.0
|
||||
margin_bottom = 110.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 112.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VelocityBox" type="VBoxContainer" parent="Margin/Container"]
|
||||
material = ExtResource( 4 )
|
||||
margin_right = 293.0
|
||||
margin_bottom = 84.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
@ -74,16 +88,15 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Container/VelocityBox"]
|
||||
margin_top = 13.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 31.0
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Margin/Container/VelocityBox"]
|
||||
margin_right = 293.0
|
||||
margin_bottom = 18.0
|
||||
custom_constants/separation = 10
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ShipTarget" type="Label" parent="Container/VelocityBox/HBoxContainer"]
|
||||
[node name="ShipTarget" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer"]
|
||||
material = ExtResource( 4 )
|
||||
margin_right = 98.0
|
||||
margin_bottom = 18.0
|
||||
|
@ -91,10 +104,10 @@ mouse_filter = 1
|
|||
theme = ExtResource( 3 )
|
||||
text = "Current target"
|
||||
|
||||
[node name="CurrentTarget" type="Label" parent="Container/VelocityBox/HBoxContainer"]
|
||||
[node name="CurrentTarget" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer"]
|
||||
material = ExtResource( 4 )
|
||||
margin_left = 108.0
|
||||
margin_right = 222.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 18.0
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 3
|
||||
|
@ -103,16 +116,16 @@ custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
|
|||
text = "2A.01/10"
|
||||
align = 2
|
||||
|
||||
[node name="HBoxContainer4" type="HBoxContainer" parent="Container/VelocityBox"]
|
||||
margin_top = 35.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 53.0
|
||||
[node name="HBoxContainer4" type="HBoxContainer" parent="Margin/Container/VelocityBox"]
|
||||
margin_top = 22.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 40.0
|
||||
custom_constants/separation = 10
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ShipTarget" type="Label" parent="Container/VelocityBox/HBoxContainer4"]
|
||||
[node name="ShipTarget" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer4"]
|
||||
material = ExtResource( 4 )
|
||||
margin_right = 110.0
|
||||
margin_bottom = 18.0
|
||||
|
@ -120,10 +133,10 @@ mouse_filter = 1
|
|||
theme = ExtResource( 3 )
|
||||
text = "Current position"
|
||||
|
||||
[node name="CurrentPosition" type="Label" parent="Container/VelocityBox/HBoxContainer4"]
|
||||
[node name="CurrentPosition" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer4"]
|
||||
material = ExtResource( 4 )
|
||||
margin_left = 120.0
|
||||
margin_right = 222.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 18.0
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 3
|
||||
|
@ -132,16 +145,16 @@ custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
|
|||
text = "0A.00/00"
|
||||
align = 2
|
||||
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="Container/VelocityBox"]
|
||||
margin_top = 57.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 75.0
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="Margin/Container/VelocityBox"]
|
||||
margin_top = 44.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 62.0
|
||||
custom_constants/separation = 10
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ShipVelocityLabel" type="Label" parent="Container/VelocityBox/HBoxContainer3"]
|
||||
[node name="ShipVelocityLabel" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer3"]
|
||||
material = ExtResource( 4 )
|
||||
margin_right = 88.0
|
||||
margin_bottom = 18.0
|
||||
|
@ -149,10 +162,10 @@ mouse_filter = 1
|
|||
theme = ExtResource( 3 )
|
||||
text = "Ship velocity"
|
||||
|
||||
[node name="CurrentSpeed" type="Label" parent="Container/VelocityBox/HBoxContainer3"]
|
||||
[node name="CurrentSpeed" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer3"]
|
||||
material = ExtResource( 4 )
|
||||
margin_left = 98.0
|
||||
margin_right = 222.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 18.0
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 3
|
||||
|
@ -160,12 +173,12 @@ theme = ExtResource( 3 )
|
|||
custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
|
||||
align = 2
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Container/VelocityBox"]
|
||||
margin_top = 79.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 97.0
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Margin/Container/VelocityBox"]
|
||||
margin_top = 66.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 84.0
|
||||
|
||||
[node name="ShipDirectionLabel" type="Label" parent="Container/VelocityBox/HBoxContainer2"]
|
||||
[node name="ShipDirectionLabel" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer2"]
|
||||
material = ExtResource( 4 )
|
||||
margin_right = 94.0
|
||||
margin_bottom = 18.0
|
||||
|
@ -173,13 +186,22 @@ mouse_filter = 1
|
|||
theme = ExtResource( 3 )
|
||||
text = "Ship direction"
|
||||
|
||||
[node name="CurrentDirection" type="Label" parent="Container/VelocityBox/HBoxContainer2"]
|
||||
[node name="CurrentDirection" type="Label" parent="Margin/Container/VelocityBox/HBoxContainer2"]
|
||||
material = ExtResource( 4 )
|
||||
margin_left = 98.0
|
||||
margin_right = 222.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 18.0
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 3
|
||||
theme = ExtResource( 3 )
|
||||
custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
|
||||
align = 2
|
||||
|
||||
[node name="Button" type="Button" parent="Margin/Container"]
|
||||
material = ExtResource( 4 )
|
||||
margin_top = 88.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 112.0
|
||||
theme = ExtResource( 3 )
|
||||
text = "Open map"
|
||||
[connection signal="pressed" from="Margin/Container/Button" to="." method="_map_button_pressed"]
|
||||
|
|
|
@ -14,13 +14,13 @@ void fragment() {
|
|||
if (col.r/col.g > 2.) {
|
||||
if (length(cable_color) == 0.) {
|
||||
if (UV.y > 0.6 && UV.y < 0.85) {
|
||||
if (float(int(UV.x * 200.) % 12) > 4.) {
|
||||
if (mod(UV.x * 200., 12.) > 4.) {
|
||||
col.rgb = vec3(0.94, 0.08, 0.08) * length(col.rgb);
|
||||
} else {
|
||||
col.rgb = vec3(0.04, 0.58, 0.98) * length(col.rgb);
|
||||
}
|
||||
} else {
|
||||
if (float(int(UV.y * 200.) % 12) > 4.) {
|
||||
if (mod(UV.y * 200., 12.) > 4.) {
|
||||
col.rgb = vec3(0.94, 0.08, 0.08) * length(col.rgb);
|
||||
} else {
|
||||
col.rgb = vec3(0.04, 0.58, 0.98) * length(col.rgb);
|
||||
|
|
|
@ -7,28 +7,30 @@ class_name GameObjectEngine
|
|||
const LIGHT_STRENGTH_MULT = 0.002
|
||||
|
||||
const MAX_ENERGY = 2
|
||||
const MAX_USAGE = 1
|
||||
|
||||
enum Direction { LEFT, RIGHT, UP, DOWN }
|
||||
|
||||
export(Direction) var direction = Direction.DOWN setget set_direction
|
||||
|
||||
onready var activationRange = $ActivationRange as ActivationRange
|
||||
onready var manager = $PowerManager as PowerManager
|
||||
|
||||
export var strength = 1.0 setget set_strength
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
if not Engine.editor_hint:
|
||||
activationRange.visible = true
|
||||
|
||||
func set_direction(dir):
|
||||
func set_direction(dir) -> void:
|
||||
direction = dir
|
||||
refresh_sprite()
|
||||
|
||||
func set_strength(val):
|
||||
func set_strength(val: float) -> void:
|
||||
strength = val
|
||||
$Light2D.energy = val * LIGHT_STRENGTH_MULT
|
||||
|
||||
func refresh_sprite():
|
||||
func refresh_sprite() -> void:
|
||||
var rot = 0
|
||||
match direction:
|
||||
Direction.DOWN:
|
||||
|
@ -46,6 +48,8 @@ func refresh_sprite():
|
|||
$Light2D.rotation = rot
|
||||
$ActivationRange.rotation = rot
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
manager.power_usage = MAX_USAGE * strength
|
||||
|
||||
func _input_event(_viewport, event, _shape_idx):
|
||||
if Engine.editor_hint:
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://Actors/Components/ActivationRange.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Actors/Objects/Engine/Engine.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Graphics/tgstation/engine-big.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Graphics/light_shadow_light.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Actors/Components/PowerManager.gd" type="Script" id=5]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 48, 48 )
|
||||
|
@ -38,3 +39,6 @@ script = ExtResource( 1 )
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="ActivationRange"]
|
||||
position = Vector2( 48, 56 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="PowerManager" type="Node" parent="."]
|
||||
script = ExtResource( 5 )
|
||||
|
|
|
@ -2,7 +2,7 @@ extends StaticBody2D
|
|||
|
||||
class_name GameObjectPowerStorage
|
||||
|
||||
const MAX_CHARGE = 100000.0
|
||||
const MAX_CHARGE = 5e5
|
||||
|
||||
var open = false
|
||||
var attached = true
|
||||
|
@ -11,7 +11,7 @@ onready var manager = $PowerManager as PowerManager
|
|||
|
||||
export var current_charge = MAX_CHARGE setget set_charge
|
||||
export var max_charge_rate = 0 setget set_max_charge
|
||||
export var max_discharge_rate = 200 setget set_max_discharge
|
||||
export var max_discharge_rate = 2000 setget set_max_discharge
|
||||
|
||||
var next_network_update = Multiplayer.SYSTEMS_UPDATE_INTERVAL
|
||||
|
||||
|
@ -20,6 +20,7 @@ func _ready() -> void:
|
|||
activationRange.visible = true
|
||||
$Control/PowerUI.set_current_charge(current_charge)
|
||||
$Control/PowerUI.set_max_charge(MAX_CHARGE)
|
||||
$Control/PowerUI.init_values(max_charge_rate, max_discharge_rate)
|
||||
set_max_charge(max_charge_rate)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
|
|
@ -3,8 +3,12 @@ extends Control
|
|||
onready var scene = $"/root/scene" as GameInstance
|
||||
|
||||
func set_current_charge(val):
|
||||
$Container/CurrentBox/HBoxContainer/CurrentChargeLabel.text = "(" + str(round(val/10)/100) + "kJ)"
|
||||
$Container/CurrentBox/HBoxContainer/CurrentChargeLabel.text = "(" + str(round(val/10)/100) + "MJ)"
|
||||
$Container/CurrentBox/ProgressBar.value = val
|
||||
|
||||
func set_max_charge(val: float):
|
||||
$Container/CurrentBox/ProgressBar.max_value = val
|
||||
|
||||
func init_values(max_charge: float, max_discharge: float):
|
||||
$Container/ChargeBox/SpinBox.value = int(max_charge)
|
||||
$Container/ChargeBox/SpinBox2.value = int(max_discharge)
|
||||
|
|
|
@ -129,7 +129,7 @@ margin_bottom = 28.0
|
|||
mouse_filter = 1
|
||||
theme = ExtResource( 3 )
|
||||
max_value = 200.0
|
||||
suffix = "W"
|
||||
suffix = "kW"
|
||||
|
||||
[node name="Discharge" type="Label" parent="Container/ChargeBox"]
|
||||
material = ExtResource( 4 )
|
||||
|
@ -148,6 +148,6 @@ margin_right = 186.0
|
|||
margin_bottom = 60.0
|
||||
mouse_filter = 1
|
||||
theme = ExtResource( 3 )
|
||||
max_value = 200.0
|
||||
max_value = 2000.0
|
||||
value = 200.0
|
||||
suffix = "W"
|
||||
suffix = "kW"
|
||||
|
|
30
Classes/Coordinates.gd
Normal file
30
Classes/Coordinates.gd
Normal file
|
@ -0,0 +1,30 @@
|
|||
class_name Coordinates
|
||||
|
||||
static func as_string(coord: Vector2, include_subcoord: bool = false) -> String:
|
||||
var x = floor(coord.x)
|
||||
var y = floor(coord.y)
|
||||
var sector_name = to_letter(int(x))
|
||||
if y < 0:
|
||||
sector_name += to_letter(int(y))
|
||||
else:
|
||||
sector_name += str(int(y))
|
||||
if include_subcoord:
|
||||
var x_sub = floor((coord.x - x) * 100)
|
||||
var y_sub = floor((coord.y - y) * 100)
|
||||
sector_name += "." + str(int(x_sub)).pad_zeros(2) + "/" + str(int(y_sub)).pad_zeros(2)
|
||||
return sector_name
|
||||
|
||||
static func to_letter(num: int) -> String:
|
||||
#var letters = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
|
||||
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
if num == 0:
|
||||
return "Α"
|
||||
elif num < 0:
|
||||
letters = "αβγδεζηθικλμνξοπρστυφχψω"
|
||||
num = abs(num)
|
||||
var out = ""
|
||||
var base = letters.length()
|
||||
while num > 0:
|
||||
out += letters.substr(num % base, 1)
|
||||
num /= base
|
||||
return out
|
5
LICENSE
Normal file
5
LICENSE
Normal file
|
@ -0,0 +1,5 @@
|
|||
Copyright 2020 Alessandro Gatti
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
16
README.md
Normal file
16
README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
# NSS Odyssey
|
||||
|
||||
**Warning: Toy project**
|
||||
|
||||
Co-op survival space sim, keep the NSS Odyssey alive and kicking while roaming in space.
|
||||
|
||||
Takes heavy inspiration (and for now, graphics) from Space Station 13 and FTL.
|
||||
|
||||
## Credits
|
||||
|
||||
- Title screen music: [Je suis un Phoenix by BlueMillenium](http://ccmixter.org/files/Bluemillenium/61325) (CC 3.0 BY-NC)
|
||||
- Title screen background: [Star Nest by Pablo Roman Andrioli](https://www.shadertoy.com/view/XlfGRj) (MIT)
|
||||
- All graphics in `Graphics/tgstation` is taken from [/tg/station](https://github.com/tgstation/tgstation) (CC 3.0 BY-SA)
|
||||
- Uses the [GOTM API library](https://github.com/PlayGotm/GDGotm) from Macaroni Studios (MIT)
|
||||
|
||||
See `LICENSE` for code license (TL;DR it's [ISC](https://en.wikipedia.org/wiki/ISC_license))
|
12
Scenes/EditorOnly/TestOdyssey.tscn
Normal file
12
Scenes/EditorOnly/TestOdyssey.tscn
Normal file
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Node
|
||||
|
||||
func _ready():
|
||||
$\"/root/Multiplayer\".gotm_mode = true # Faster startup
|
||||
$\"/root/Multiplayer\".host()
|
||||
"
|
||||
|
||||
[node name="Node" type="Node"]
|
||||
script = SubResource( 1 )
|
|
@ -10,9 +10,12 @@ onready var systems = $systems
|
|||
onready var netgame = $"/root/Multiplayer"
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
ui.connect("command", world, "process_command")
|
||||
if netgame.hosting:
|
||||
world.load_map(netgame.get_current_map())
|
||||
world.map.current_ship_position = Vector2(randf() * 1e4, randf() * 1e4)
|
||||
world.map.current_ship_target = world.map.current_ship_position + Vector2(-3, 3)
|
||||
rpc("spawn_player", 1)
|
||||
else:
|
||||
world.load_map(GameWorld.Map.EMPTY)
|
||||
|
@ -49,13 +52,13 @@ master func ready_to_spawn() -> void:
|
|||
rpc("spawn_player", id)
|
||||
|
||||
remotesync func spawn_player(id):
|
||||
print("must spawn ", id)
|
||||
world.spawn_player(id, multiplayer.get_network_unique_id() == id)
|
||||
|
||||
func process_command(cmd: UICommand):
|
||||
match cmd.cmd_type:
|
||||
UICommand.CommandType.SetShipSpeed:
|
||||
world.map.ship_speed = cmd.cmd_args[0]
|
||||
UICommand.CommandType.SetShipDirection:
|
||||
world.map.ship_direction = cmd.cmd_args[0]
|
||||
remotesync func process_command(cmd: UICommand):
|
||||
pass
|
||||
# match cmd.cmd_type:
|
||||
# UICommand.CommandType.SetShipSpeed:
|
||||
# world.map.ship_speed = cmd.cmd_args[0]
|
||||
# UICommand.CommandType.SetShipDirection:
|
||||
# world.map.ship_direction = cmd.cmd_args[0]
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ func join(server):
|
|||
var success = yield(server.join(), "completed")
|
||||
addr = Gotm.lobby.host.address
|
||||
else:
|
||||
addr = server.addr
|
||||
addr = server.address
|
||||
|
||||
peer.create_client(addr, SERVER_PORT)
|
||||
get_tree().network_peer = peer
|
||||
|
|
|
@ -12,9 +12,20 @@ var current_ship_target = Vector2.ZERO
|
|||
var current_ship_direction = 0
|
||||
var current_ship_speed = 0
|
||||
|
||||
const SPEED_EASE = 0.5
|
||||
const DIRECTION_EASE = 0.5
|
||||
puppet var pup_ship_position = Vector2.ZERO
|
||||
puppet var pup_ship_target = Vector2.ZERO
|
||||
puppet var pup_ship_direction = 0
|
||||
puppet var pup_ship_speed = 0
|
||||
|
||||
const MAX_ACCELERATION = 0.03
|
||||
const DIRECTION_EASE = 0.4
|
||||
const EPSILON = 0.01
|
||||
const SCROLL_MULTIPLIER = 1e4
|
||||
const ENGINE_MULTIPLIER = 5000
|
||||
const MAX_SPEED = 0.2 # in Sectors/Second
|
||||
const SLOW_SPEED = 0.02
|
||||
const SLOW_SPEED_THRESHOLD = 0.2
|
||||
const NO_SPEED_THRESHOLD = 0.1
|
||||
|
||||
const ProbeElectricity = preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
|
||||
|
||||
|
@ -42,22 +53,55 @@ func _ready():
|
|||
# Electricity setup
|
||||
make_electric_probes($cables, "Wire")
|
||||
|
||||
# Set engines to expected power level
|
||||
set_engine_strength(current_ship_speed)
|
||||
|
||||
func _process(delta: float):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
|
||||
var current_speed_ratio = current_ship_speed / MAX_SPEED
|
||||
|
||||
# Ease ship speed/direction changes
|
||||
if abs(ship_direction - current_ship_direction) < EPSILON:
|
||||
current_ship_direction = ship_direction
|
||||
else:
|
||||
current_ship_direction = lerp(current_ship_direction, ship_direction, delta * DIRECTION_EASE)
|
||||
if abs(ship_speed - current_ship_speed) < EPSILON:
|
||||
current_ship_direction = lerp(current_ship_direction, ship_direction, delta * current_speed_ratio * DIRECTION_EASE)
|
||||
var speed_delta = ship_speed - current_ship_speed
|
||||
if abs(speed_delta) < EPSILON:
|
||||
current_ship_speed = ship_speed
|
||||
else:
|
||||
current_ship_speed = lerp(current_ship_speed, ship_speed, delta * SPEED_EASE)
|
||||
set_engine_strength(current_ship_speed)
|
||||
$deepspace.rotation = current_ship_direction-PI/2
|
||||
$deepspace.region_rect.position += Vector2(sin(current_ship_direction), cos(current_ship_direction)) * current_ship_speed * delta
|
||||
current_ship_speed += MAX_ACCELERATION * max(0.1, 1-ease(current_speed_ratio, 0.6)) * delta * sign(speed_delta)
|
||||
set_engine_strength(current_ship_speed * ENGINE_MULTIPLIER)
|
||||
|
||||
$deepspace.rotation = -current_ship_direction-PI/2
|
||||
$deepspace.region_rect.position += Vector2(-sin(current_ship_direction), cos(current_ship_direction)) * current_ship_speed * SCROLL_MULTIPLIER * delta
|
||||
|
||||
func _physics_process(delta):
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
if is_network_master():
|
||||
var distance = current_ship_position.distance_to(current_ship_target)
|
||||
if distance > NO_SPEED_THRESHOLD:
|
||||
ship_direction = current_ship_target.angle_to_point(current_ship_position)
|
||||
if distance < SLOW_SPEED_THRESHOLD:
|
||||
ship_speed = SLOW_SPEED
|
||||
elif current_ship_speed == 0 or distance / current_ship_speed > ease(current_ship_speed, 2.8)*4000:
|
||||
ship_speed = MAX_SPEED
|
||||
else:
|
||||
ship_speed = 0
|
||||
rset("pup_ship_direction", ship_direction)
|
||||
rset("pup_ship_speed", ship_speed)
|
||||
else:
|
||||
ship_speed = 0
|
||||
rset("pup_ship_speed", ship_speed)
|
||||
if current_ship_speed > EPSILON:
|
||||
current_ship_position += (Vector2.RIGHT * current_ship_speed * delta).rotated(current_ship_direction)
|
||||
rset("pup_ship_position", current_ship_position)
|
||||
else:
|
||||
ship_direction = pup_ship_direction
|
||||
ship_speed = pup_ship_speed
|
||||
current_ship_position = pup_ship_position
|
||||
|
||||
# Serialization / Deserialization
|
||||
|
||||
|
@ -82,22 +126,41 @@ func serialize() -> Dictionary:
|
|||
"objects": objects,
|
||||
"lights": lights,
|
||||
"sockets": sockets,
|
||||
"pois": pois
|
||||
"pois": pois,
|
||||
"ship": {
|
||||
"position": current_ship_position,
|
||||
"target": current_ship_target,
|
||||
"set_speed": ship_speed,
|
||||
"set_direction": ship_direction,
|
||||
"speed": current_ship_speed,
|
||||
"direction": current_ship_direction
|
||||
}
|
||||
}
|
||||
|
||||
func deserialize(data: Dictionary) -> void:
|
||||
# Create maps
|
||||
for tilemap in data["tilemaps"]:
|
||||
var tilemap_node = get_node(tilemap) as TileMap
|
||||
for tile in data["tilemaps"][tilemap]:
|
||||
tilemap_node.set_cellv(tile[0], tile[1])
|
||||
tilemap_node.update_bitmask_region()
|
||||
tilemap_node.update_dirty_quadrants()
|
||||
|
||||
# Create objects
|
||||
deserialize_children($engines, data["engines"])
|
||||
deserialize_children($objects, data["objects"])
|
||||
deserialize_children($lights, data["lights"])
|
||||
deserialize_children($pois, data["pois"])
|
||||
deserialize_children($sockets, data["sockets"])
|
||||
|
||||
# Set ship parameters
|
||||
current_ship_position = data["ship"]["position"]
|
||||
current_ship_target = data["ship"]["target"]
|
||||
ship_speed = data["ship"]["set_speed"]
|
||||
ship_direction = data["ship"]["set_direction"]
|
||||
current_ship_speed = data["ship"]["speed"]
|
||||
current_ship_direction = data["ship"]["direction"]
|
||||
|
||||
# Run autotile conversions and generate occlusions
|
||||
$walls.run_conversions()
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ color = Color( 0, 0, 0, 1 )
|
|||
|
||||
[node name="deepspace" type="Sprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
position = Vector2( 208, 256 )
|
||||
texture = ExtResource( 7 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 10000, 10000 )
|
||||
|
@ -56,7 +57,7 @@ cell_size = Vector2( 32, 32 )
|
|||
cell_quadrant_size = 32
|
||||
occluder_light_mask = -2147483647
|
||||
format = 1
|
||||
tile_data = PoolIntArray( -524284, 0, 131073, -393224, 0, 131073, -393217, 0, 131073, -458748, 0, 65539, -458744, 0, 131073, -327689, 0, 65537, -327688, 0, 2, -327687, 0, 1, -327686, 0, 65536, -327685, 0, 196608, -327681, 0, 65539, -393212, 0, 65539, -393208, 0, 65539, -262153, 0, 65539, -262151, 0, 65539, -262149, 0, 65538, -262148, 0, 65536, -262147, 0, 1, -262146, 0, 65536, -262145, 0, 2, -327680, 0, 65536, -327679, 0, 65536, -327678, 0, 1, -327677, 0, 65536, -327676, 0, 2, -327675, 0, 65536, -327674, 0, 65536, -327673, 0, 65536, -327672, 0, 131074, -196617, 0, 65539, -196615, 0, 131075, -196611, 0, 131075, -262142, 0, 65539, -262136, 0, 65539, -131081, 0, 65538, -131080, 0, 196608, -196606, 0, 65539, -196600, 0, 65539, -65544, 0, 131075, -131070, 0, 131075, -131066, 0, 65537, -131065, 0, 65536, -131064, 0, 196611, -65530, 0, 65539, 6, 0, 65539, 65542, 0, 65539, 131078, 0, 65539, 196614, 0, 65539, 327676, 0, 131073, 262146, 0, 131073, 262150, 0, 65539, 262154, 0, 131073, 262160, 0, 131073, 393212, 0, 65539, 327682, 0, 65539, 327686, 0, 65539, 327690, 0, 65539, 327696, 0, 65539, 458747, 0, 65537, 458748, 0, 2, 458749, 0, 65536, 458750, 0, 65536, 458751, 0, 65536, 393216, 0, 65536, 393217, 0, 65536, 393218, 0, 2, 393219, 0, 65536, 393220, 0, 65536, 393221, 0, 65536, 393222, 0, 196610, 393223, 0, 65536, 393224, 0, 65536, 393225, 0, 65536, 393226, 0, 2, 393227, 0, 65536, 393228, 0, 65536, 393229, 0, 65536, 393230, 0, 65536, 393231, 0, 65536, 393232, 0, 2, 393233, 0, 196608, 524283, 0, 65539, 458758, 0, 65539, 458769, 0, 65539, 589819, 0, 65539, 524294, 0, 65539, 524305, 0, 65539, 655355, 0, 65538, 655356, 0, 1, 655357, 0, 65536, 655358, 0, 65536, 655359, 0, 65536, 589824, 0, 65536, 589825, 0, 65536, 589826, 0, 1, 589827, 0, 65536, 589828, 0, 65536, 589829, 0, 65536, 589830, 0, 196610, 589831, 0, 65536, 589832, 0, 65536, 589833, 0, 65536, 589834, 0, 1, 589835, 0, 65536, 589836, 0, 65536, 589837, 0, 65536, 589838, 0, 65536, 589839, 0, 65536, 589840, 0, 1, 589841, 0, 196611, 720892, 0, 65539, 655362, 0, 65539, 655366, 0, 65539, 655370, 0, 65539, 655376, 0, 65539, 786428, 0, 131075, 720898, 0, 131075, 720902, 0, 65539, 720906, 0, 131075, 720912, 0, 131075, 786438, 0, 65539, 851974, 0, 65539, 917510, 0, 65539, 983046, 0, 65539, 1048582, 0, 65539, 1179640, 0, 131073, 1114113, 0, 131073, 1114118, 0, 65539, 1245176, 0, 65538, 1245177, 0, 65536, 1245178, 0, 65536, 1245179, 0, 65536, 1245180, 0, 65536, 1245181, 0, 65536, 1245182, 0, 65536, 1245183, 0, 65536, 1179648, 0, 65536, 1179649, 0, 2, 1179650, 0, 65536, 1179651, 0, 65536, 1179652, 0, 65536, 1179653, 0, 65536, 1179654, 0, 131074, 1245190, 0, 65539, 1310726, 0, 65539, 1441784, 0, 65537, 1441785, 0, 65536, 1441786, 0, 65536, 1441787, 0, 65536, 1441788, 0, 65536, 1441789, 0, 65536, 1441790, 0, 65536, 1441791, 0, 65536, 1376256, 0, 65536, 1376257, 0, 65536, 1376258, 0, 1, 1376259, 0, 65536, 1376260, 0, 65536, 1376261, 0, 65536, 1376262, 0, 2, 1376263, 0, 65536, 1376264, 0, 196608, 1507320, 0, 131075, 1441794, 0, 131075, 1441800, 0, 131075 )
|
||||
tile_data = PoolIntArray( -524284, 0, 131073, -393224, 0, 131073, -393217, 0, 131073, -458748, 0, 65539, -458744, 0, 131073, -327689, 0, 65537, -327688, 0, 2, -327687, 0, 1, -327686, 0, 65536, -327685, 0, 196608, -327681, 0, 65539, -393212, 0, 65539, -393208, 0, 65539, -262153, 0, 65539, -262151, 0, 65539, -262149, 0, 65538, -262148, 0, 65536, -262147, 0, 1, -262146, 0, 65536, -262145, 0, 2, -327680, 0, 65536, -327679, 0, 65536, -327678, 0, 1, -327677, 0, 65536, -327676, 0, 2, -327675, 0, 65536, -327674, 0, 65536, -327673, 0, 65536, -327672, 0, 131074, -196617, 0, 65539, -196615, 0, 131075, -196611, 0, 131075, -262142, 0, 65539, -262136, 0, 65539, -131081, 0, 65538, -131080, 0, 196608, -196606, 0, 65539, -196600, 0, 65539, -65544, 0, 131075, -131070, 0, 131075, -131066, 0, 65537, -131065, 0, 65536, -131064, 0, 196611, -65530, 0, 65539, 6, 0, 65539, 65542, 0, 65539, 131078, 0, 65539, 196614, 0, 65539, 327673, 0, 131072, 327674, 0, 65536, 327675, 0, 65536, 327676, 0, 196608, 262146, 0, 131073, 262150, 0, 65539, 262154, 0, 131073, 262160, 0, 131073, 393212, 0, 65539, 327682, 0, 65539, 327686, 0, 65539, 327690, 0, 65539, 327696, 0, 65539, 458747, 0, 65537, 458748, 0, 2, 458749, 0, 65536, 458750, 0, 65536, 458751, 0, 65536, 393216, 0, 65536, 393217, 0, 65536, 393218, 0, 2, 393219, 0, 65536, 393220, 0, 65536, 393221, 0, 65536, 393222, 0, 196610, 393223, 0, 65536, 393224, 0, 65536, 393225, 0, 65536, 393226, 0, 2, 393227, 0, 65536, 393228, 0, 65536, 393229, 0, 65536, 393230, 0, 65536, 393231, 0, 65536, 393232, 0, 2, 393233, 0, 196608, 524276, 0, 131072, 524277, 0, 65536, 524278, 0, 65536, 524279, 0, 65536, 524280, 0, 65536, 524281, 0, 65536, 524282, 0, 65536, 524283, 0, 131074, 458758, 0, 65539, 458769, 0, 65539, 589819, 0, 65539, 524294, 0, 65539, 524305, 0, 65539, 655355, 0, 65538, 655356, 0, 1, 655357, 0, 65536, 655358, 0, 65536, 655359, 0, 65536, 589824, 0, 65536, 589825, 0, 65536, 589826, 0, 1, 589827, 0, 65536, 589828, 0, 65536, 589829, 0, 65536, 589830, 0, 196610, 589831, 0, 65536, 589832, 0, 65536, 589833, 0, 65536, 589834, 0, 1, 589835, 0, 65536, 589836, 0, 65536, 589837, 0, 65536, 589838, 0, 65536, 589839, 0, 65536, 589840, 0, 1, 589841, 0, 196611, 720892, 0, 65539, 655362, 0, 65539, 655366, 0, 65539, 655370, 0, 65539, 655376, 0, 65539, 786425, 0, 131072, 786426, 0, 65536, 786427, 0, 65536, 786428, 0, 196611, 720898, 0, 131075, 720902, 0, 65539, 720906, 0, 131075, 720912, 0, 131075, 786438, 0, 65539, 851974, 0, 65539, 917510, 0, 65539, 983046, 0, 65539, 1048582, 0, 65539, 1179640, 0, 131073, 1114113, 0, 131073, 1114118, 0, 65539, 1245176, 0, 65538, 1245177, 0, 65536, 1245178, 0, 65536, 1245179, 0, 65536, 1245180, 0, 65536, 1245181, 0, 65536, 1245182, 0, 65536, 1245183, 0, 65536, 1179648, 0, 65536, 1179649, 0, 2, 1179650, 0, 65536, 1179651, 0, 65536, 1179652, 0, 65536, 1179653, 0, 65536, 1179654, 0, 131074, 1245190, 0, 65539, 1310726, 0, 65539, 1441784, 0, 65537, 1441785, 0, 65536, 1441786, 0, 65536, 1441787, 0, 65536, 1441788, 0, 65536, 1441789, 0, 65536, 1441790, 0, 65536, 1441791, 0, 65536, 1376256, 0, 65536, 1376257, 0, 65536, 1376258, 0, 1, 1376259, 0, 65536, 1376260, 0, 65536, 1376261, 0, 65536, 1376262, 0, 2, 1376263, 0, 65536, 1376264, 0, 196608, 1507320, 0, 131075, 1441794, 0, 131075, 1441800, 0, 131075 )
|
||||
|
||||
[node name="floor" type="TileMap" parent="."]
|
||||
z_index = 3
|
||||
|
@ -455,6 +456,24 @@ direction = 3
|
|||
connectionPaths = [ NodePath("../../lights/Lighttube23") ]
|
||||
flow = 1
|
||||
|
||||
[node name="ElectricSocket46" parent="sockets" instance=ExtResource( 14 )]
|
||||
position = Vector2( -384, 224 )
|
||||
direction = 0
|
||||
connectionPaths = [ NodePath("../../engines/Engine2") ]
|
||||
flow = 1
|
||||
|
||||
[node name="ElectricSocket47" parent="sockets" instance=ExtResource( 14 )]
|
||||
position = Vector2( -224, 128 )
|
||||
direction = 0
|
||||
connectionPaths = [ NodePath("../../engines/Engine3") ]
|
||||
flow = 1
|
||||
|
||||
[node name="ElectricSocket48" parent="sockets" instance=ExtResource( 14 )]
|
||||
position = Vector2( -224, 352 )
|
||||
direction = 0
|
||||
connectionPaths = [ NodePath("../../engines/Engine") ]
|
||||
flow = 1
|
||||
|
||||
[node name="lights" type="Node2D" parent="."]
|
||||
modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
|
||||
z_index = 11
|
||||
|
@ -551,3 +570,4 @@ direction = 2
|
|||
z_index = 999
|
||||
|
||||
[node name="SpawnpointPlayer" parent="pois" instance=ExtResource( 15 )]
|
||||
position = Vector2( 560, 256 )
|
||||
|
|
|
@ -35,7 +35,7 @@ border_width_left = 4
|
|||
border_width_top = 4
|
||||
border_width_right = 4
|
||||
border_width_bottom = 4
|
||||
border_color = Color( 0.27301, 0.417506, 0.984375, 0.392157 )
|
||||
border_color = Color( 0.27451, 0.415686, 0.984314, 0.392157 )
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
|
|
|
@ -16,3 +16,9 @@ func _server_option_chosen(id) -> void:
|
|||
match id:
|
||||
ServerMenuItem.SERVER_INFO:
|
||||
$ServerInfoPopup.popup_centered()
|
||||
|
||||
func open_map_popup() -> void:
|
||||
$MapPopup.popup_centered_ratio()
|
||||
|
||||
func close_map_popup() -> void:
|
||||
$MapPopup.visible = false
|
||||
|
|
|
@ -33,20 +33,79 @@ size_flags_horizontal = 3
|
|||
size_flags_vertical = 3
|
||||
custom_constants/separation = 10
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
margin_right = 528.0
|
||||
margin_bottom = 18.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
margin_right = 104.0
|
||||
margin_bottom = 18.0
|
||||
text = "S01\\AR SYSTEM"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 108.0
|
||||
margin_right = 528.0
|
||||
margin_bottom = 18.0
|
||||
size_flags_horizontal = 3
|
||||
alignment = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_left = 330.0
|
||||
margin_right = 368.0
|
||||
margin_bottom = 18.0
|
||||
text = "SPD: "
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CurrentSpeed" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_left = 372.0
|
||||
margin_right = 372.0
|
||||
margin_bottom = 18.0
|
||||
custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label3" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_left = 376.0
|
||||
margin_right = 416.0
|
||||
margin_bottom = 18.0
|
||||
text = "ANGL:"
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CurrentAngle" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_left = 420.0
|
||||
margin_right = 420.0
|
||||
margin_bottom = 18.0
|
||||
custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 )
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Map" type="Control" parent="MarginContainer/VBoxContainer"]
|
||||
margin_top = 28.0
|
||||
margin_bottom = 28.0
|
||||
margin_right = 528.0
|
||||
margin_bottom = 446.0
|
||||
rect_clip_content = true
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 4 )
|
||||
background = ExtResource( 2 )
|
||||
font = ExtResource( 3 )
|
||||
[connection signal="about_to_show" from="." to="MarginContainer/VBoxContainer/Map" method="_reset_position"]
|
||||
|
|
|
@ -3,35 +3,94 @@ extends Control
|
|||
export var cell_size = 100
|
||||
export var bgzoom = 50
|
||||
|
||||
const BORDER_WIDTH = 4
|
||||
const BORDER_LENGTH = 30
|
||||
const RADAR_EFFECT_DELAY = 1
|
||||
|
||||
export(Texture) var background
|
||||
export(Font) var font
|
||||
|
||||
var dragging = false
|
||||
var origin = Vector2(randf() * -1e4, randf() * -1e4)
|
||||
var origin = Vector2.ZERO
|
||||
var last_origin = origin
|
||||
var last_mouse_pos = Vector2.ZERO
|
||||
var set_position = true
|
||||
var radar_next_remaining = RADAR_EFFECT_DELAY
|
||||
|
||||
onready var scene = $"/root/scene"
|
||||
onready var speed_text = $"../HBoxContainer/HBoxContainer/CurrentSpeed"
|
||||
onready var dir_text = $"../HBoxContainer/HBoxContainer/CurrentAngle"
|
||||
|
||||
var last_pos = []
|
||||
|
||||
func _physics_process(delta):
|
||||
radar_next_remaining -= delta
|
||||
if radar_next_remaining < 0:
|
||||
var current_position = scene.world.map.current_ship_position * 100
|
||||
last_pos.append(current_position)
|
||||
if last_pos.size() > 20:
|
||||
last_pos.pop_front()
|
||||
radar_next_remaining = RADAR_EFFECT_DELAY
|
||||
if not visible:
|
||||
return
|
||||
speed_text.text = str(round(scene.world.map.current_ship_speed * 10000)) + " u/s"
|
||||
dir_text.text = str(round(rad2deg(scene.world.map.current_ship_direction))) + " deg"
|
||||
update()
|
||||
|
||||
func _draw():
|
||||
var win_size = get_global_rect().size
|
||||
var current_position = scene.world.map.current_ship_position * 100
|
||||
if set_position:
|
||||
origin = current_position - win_size/2.0
|
||||
last_origin = origin
|
||||
if win_size.x > 0:
|
||||
set_position = false
|
||||
var cols = int(ceil(win_size.x/cell_size))
|
||||
var rows = int(ceil(win_size.y/cell_size))
|
||||
var xoffset = float(int(origin.x) % cell_size)
|
||||
var yoffset = float(int(origin.y) % cell_size)
|
||||
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):
|
||||
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)
|
||||
for i in range(0, rows):
|
||||
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 y in range(-1, rows+1):
|
||||
var real_x = x - int(origin.x/cell_size)
|
||||
var real_y = y - int(origin.y/cell_size)
|
||||
var sector_name = to_letter(real_x)
|
||||
if real_y < 0:
|
||||
sector_name += to_letter(real_y)
|
||||
else:
|
||||
sector_name += str(real_y)
|
||||
draw_string(font, Vector2(x * cell_size + 6 + xoffset, y * cell_size + 20 + yoffset), sector_name, Color(1,1,1,0.5))
|
||||
var real_x = x + int(origin.x/cell_size)
|
||||
var real_y = y + int(origin.y/cell_size)
|
||||
var sector_name = Coordinates.as_string(Vector2(real_x, real_y))
|
||||
draw_string(font, Vector2(x * cell_size + 6 - xoffset, y * cell_size + 20 - yoffset), sector_name, Color(1,1,1,0.5))
|
||||
|
||||
var viewport = Rect2(origin, win_size)
|
||||
|
||||
var point_count = last_pos.size()
|
||||
for pos_index in range(0, point_count):
|
||||
draw_circle(last_pos[pos_index] - origin, 2, Color(1, 0, 0, pos_index*1.0/point_count))
|
||||
|
||||
draw_target(viewport, current_position, Color.red)
|
||||
|
||||
var current_target = scene.world.map.current_ship_target
|
||||
if current_target != null:
|
||||
var current_target_adj = current_target * 100
|
||||
draw_target(viewport, current_target_adj, Color.green)
|
||||
draw_line(current_position - origin, current_target_adj - origin, Color.darkcyan)
|
||||
|
||||
func draw_target(viewport: Rect2, position: Vector2, color: Color):
|
||||
# Check if target is in range
|
||||
if viewport.has_point(position):
|
||||
draw_circle(position - viewport.position, 5, color)
|
||||
else:
|
||||
# Draw line pointing to target
|
||||
var relative_pos = position - viewport.position
|
||||
var clamped = Vector2(clamp(relative_pos.x, 0, viewport.size.x), clamp(relative_pos.y, 0, viewport.size.y))
|
||||
if relative_pos.x < 0:
|
||||
draw_line(Vector2(0, clamped.y-BORDER_LENGTH/2), Vector2(0, clamped.y+BORDER_LENGTH/2), color, BORDER_WIDTH)
|
||||
elif relative_pos.x > viewport.size.x:
|
||||
draw_line(Vector2(viewport.size.x, clamped.y-BORDER_LENGTH/2), Vector2(viewport.size.x, clamped.y+BORDER_LENGTH/2), color, BORDER_WIDTH)
|
||||
if relative_pos.y < 0:
|
||||
draw_line(Vector2(clamped.x-BORDER_LENGTH/2, 0), Vector2(clamped.x+BORDER_LENGTH/2, 0), color, BORDER_WIDTH)
|
||||
elif relative_pos.y > viewport.size.y:
|
||||
draw_line(Vector2(clamped.x-BORDER_LENGTH/2, viewport.size.y), Vector2(clamped.x+BORDER_LENGTH/2, viewport.size.y), color, BORDER_WIDTH)
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton:
|
||||
|
@ -41,20 +100,8 @@ func _input(event):
|
|||
update()
|
||||
elif event is InputEventMouseMotion:
|
||||
if dragging:
|
||||
origin = last_origin + (event.position - last_mouse_pos)
|
||||
origin = last_origin - (event.position - last_mouse_pos)
|
||||
update()
|
||||
|
||||
func to_letter(num: int) -> String:
|
||||
#var letters = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
|
||||
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
if num == 0:
|
||||
return "Α"
|
||||
elif num < 0:
|
||||
letters = "αβγδεζηθικλμνξοπρστυφχψω"
|
||||
num = abs(num)
|
||||
var out = ""
|
||||
var base = letters.length()
|
||||
while num > 0:
|
||||
out += letters.substr(num % base, 1)
|
||||
num /= base
|
||||
return out
|
||||
func _reset_position():
|
||||
set_position = true
|
||||
|
|
|
@ -6,7 +6,7 @@ runnable=true
|
|||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
exclude_filter="Scenes/EditorOnly/*"
|
||||
export_path="export/odyssey.exe"
|
||||
patch_list=PoolStringArray( )
|
||||
script_export_mode=1
|
||||
|
@ -49,7 +49,7 @@ runnable=true
|
|||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
exclude_filter="Scenes/EditorOnly/*"
|
||||
export_path="export/html/odyssey.html"
|
||||
patch_list=PoolStringArray( )
|
||||
script_export_mode=1
|
||||
|
|
|
@ -14,6 +14,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://Actors/Components/ActivationRange.gd"
|
||||
}, {
|
||||
"base": "Reference",
|
||||
"class": "Coordinates",
|
||||
"language": "GDScript",
|
||||
"path": "res://Classes/Coordinates.gd"
|
||||
}, {
|
||||
"base": "Area2D",
|
||||
"class": "ElectricSocket",
|
||||
"language": "GDScript",
|
||||
|
@ -146,6 +151,7 @@ _global_script_classes=[ {
|
|||
} ]
|
||||
_global_script_class_icons={
|
||||
"ActivationRange": "",
|
||||
"Coordinates": "",
|
||||
"ElectricSocket": "",
|
||||
"GameInstance": "",
|
||||
"GameMap": "",
|
||||
|
|
Reference in a new issue