From c5b48c1a8a37ff1019b8bb7a506d056e532eab98 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Tue, 7 Jul 2020 18:08:56 +0200 Subject: [PATCH] Add runtime map, Add current speed/dir to controlcomp --- Actors/Objects/Computer/Computer.gd | 13 +- Actors/Objects/Computer/Computer.tscn | 2 +- Actors/Objects/Computer/UI/ControlComp.gd | 6 + Actors/Objects/Computer/UI/ControlComp.tscn | 60 ++++++-- Actors/Objects/Door/Door.gd | 4 +- Actors/Objects/Engine/Engine.gd | 2 +- Actors/Objects/Lightbulb/Lightbulb.gd | 2 +- Actors/Objects/PowerStorage/PowerStorage.gd | 3 + Actors/Objects/PowerStorage/PowerStorage.tscn | 18 +++ Actors/Player/Player.gd | 14 +- Graphics/tgstation/smes.png | Bin 0 -> 908 bytes Graphics/tgstation/smes.png.import | 34 +++++ Scenes/Game.tscn | 7 +- Scenes/Map.gd | 2 +- Scenes/Maps/odyssey.tscn | 35 ++++- Scenes/Maps/runtime.gd | 10 ++ Scenes/Maps/runtime.tscn | 142 ++++++++++++++++++ Scenes/Rendering/Occluder.gd | 1 - project.godot | 6 + 19 files changed, 325 insertions(+), 36 deletions(-) create mode 100644 Actors/Objects/PowerStorage/PowerStorage.gd create mode 100644 Actors/Objects/PowerStorage/PowerStorage.tscn create mode 100644 Graphics/tgstation/smes.png create mode 100644 Graphics/tgstation/smes.png.import create mode 100644 Scenes/Maps/runtime.gd create mode 100644 Scenes/Maps/runtime.tscn diff --git a/Actors/Objects/Computer/Computer.gd b/Actors/Objects/Computer/Computer.gd index e93dd9e..57b1731 100644 --- a/Actors/Objects/Computer/Computer.gd +++ b/Actors/Objects/Computer/Computer.gd @@ -5,7 +5,7 @@ extends StaticBody2D class_name GameObjectComputer enum Direction { LEFT, RIGHT, UP, DOWN } -enum ComputerType { ShipCommand, Comms, Medical, Research, ShipEngine, Atmos } +enum ComputerType { ShipCommand, Comms, Medical, Research, Energy, ShipEngine, Atmos } export(Direction) var direction = Direction.DOWN setget set_direction export(ComputerType) var computer_type = ComputerType.ShipCommand setget set_type @@ -30,10 +30,13 @@ func set_type(val): screen_region_offset = Vector2(0, 64) ComputerType.Research: screen_region_offset = Vector2(128, 0) - ComputerType.ShipEngine: + ComputerType.Energy: screen_region_offset = Vector2(128, 224) ComputerType.Atmos: + screen_region_offset = Vector2(128, 192) + ComputerType.ShipEngine: screen_region_offset = Vector2(0, 256) + refresh_sprite() func set_direction(dir): @@ -45,15 +48,19 @@ func refresh_sprite(): Direction.DOWN: $computer.region_rect.position = Vector2(0, 0) $computer/screen.region_rect.position = screen_region_offset + Vector2(0, 0) + $computer/screen/Light2D.rotation = 0 Direction.UP: $computer.region_rect.position = Vector2(0, 32) $computer/screen.region_rect.position = screen_region_offset + Vector2(32, 0) + $computer/screen/Light2D.rotation = PI Direction.LEFT: $computer.region_rect.position = Vector2(32, 32) $computer/screen.region_rect.position = screen_region_offset + Vector2(96, 0) + $computer/screen/Light2D.rotation = PI/2 Direction.RIGHT: $computer.region_rect.position = Vector2(32, 0) $computer/screen.region_rect.position = screen_region_offset + Vector2(64, 0) + $computer/screen/Light2D.rotation = -PI/2 func manage_controls(show: bool): match computer_type: @@ -65,7 +72,7 @@ func _input(event): open = false $UIAnimation.play("fadeout") -func _input_event(viewport, event, shape_idx): +func _input_event(_viewport, event, _shape_idx): if Engine.editor_hint: return if event is InputEventMouseButton and event.pressed and not open: diff --git a/Actors/Objects/Computer/Computer.tscn b/Actors/Objects/Computer/Computer.tscn index 4a1404a..68fa667 100644 --- a/Actors/Objects/Computer/Computer.tscn +++ b/Actors/Objects/Computer/Computer.tscn @@ -119,7 +119,7 @@ region_rect = Rect2( 0, 0, 32, 32 ) position = Vector2( 16, 16 ) texture = ExtResource( 5 ) texture_scale = 0.5 -energy = 0.4 +energy = 0.5 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2( 16, 16 ) diff --git a/Actors/Objects/Computer/UI/ControlComp.gd b/Actors/Objects/Computer/UI/ControlComp.gd index 29caefd..e7ebd20 100644 --- a/Actors/Objects/Computer/UI/ControlComp.gd +++ b/Actors/Objects/Computer/UI/ControlComp.gd @@ -5,6 +5,12 @@ onready var scene = $"/root/scene" as GameInstance func _ready(): pass +func _physics_process(delta): + var speed_str = "(" + str(round(scene.world.map.current_ship_speed)) + " u/s)" + $Container/VelocityBox/HBoxContainer/CurrentSpeed.text = speed_str + var dir_str = "(" + str(round(rad2deg(scene.world.map.current_ship_direction))) + " deg)" + $Container/DirectionBox/HBoxContainer/CurrentDirection.text = dir_str + func _ship_velocity_changed(value): scene.process_command(UICommand.new(UICommand.CommandType.SetShipSpeed, [value])) diff --git a/Actors/Objects/Computer/UI/ControlComp.tscn b/Actors/Objects/Computer/UI/ControlComp.tscn index fc5c766..fd4bef9 100644 --- a/Actors/Objects/Computer/UI/ControlComp.tscn +++ b/Actors/Objects/Computer/UI/ControlComp.tscn @@ -64,7 +64,7 @@ __meta__ = { [node name="VelocityBox" type="VBoxContainer" parent="Container"] material = ExtResource( 4 ) margin_right = 180.0 -margin_bottom = 45.0 +margin_bottom = 51.0 size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 1 @@ -72,20 +72,37 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="ShipVelocityLabel" type="Label" parent="Container/VelocityBox"] -material = ExtResource( 4 ) -margin_top = 3.0 +[node name="HBoxContainer" type="HBoxContainer" parent="Container/VelocityBox"] +margin_top = 6.0 margin_right = 180.0 -margin_bottom = 21.0 +margin_bottom = 24.0 +custom_constants/separation = 10 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ShipVelocityLabel" type="Label" parent="Container/VelocityBox/HBoxContainer"] +material = ExtResource( 4 ) +margin_right = 88.0 +margin_bottom = 18.0 mouse_filter = 1 theme = ExtResource( 3 ) text = "Ship velocity" +[node name="CurrentSpeed" type="Label" parent="Container/VelocityBox/HBoxContainer"] +material = ExtResource( 4 ) +margin_left = 98.0 +margin_right = 98.0 +margin_bottom = 18.0 +mouse_filter = 1 +theme = ExtResource( 3 ) +custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 ) + [node name="HSlider" type="HSlider" parent="Container/VelocityBox"] material = ExtResource( 4 ) -margin_top = 25.0 +margin_top = 28.0 margin_right = 180.0 -margin_bottom = 41.0 +margin_bottom = 44.0 mouse_filter = 1 max_value = 1000.0 value = 1000.0 @@ -94,9 +111,9 @@ ticks_on_borders = true [node name="DirectionBox" type="VBoxContainer" parent="Container"] material = ExtResource( 4 ) -margin_top = 65.0 +margin_top = 71.0 margin_right = 180.0 -margin_bottom = 110.0 +margin_bottom = 122.0 size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 1 @@ -104,20 +121,33 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="ShipDirectionLabel" type="Label" parent="Container/DirectionBox"] -material = ExtResource( 4 ) -margin_top = 3.0 +[node name="HBoxContainer" type="HBoxContainer" parent="Container/DirectionBox"] +margin_top = 6.0 margin_right = 180.0 -margin_bottom = 21.0 +margin_bottom = 24.0 + +[node name="ShipDirectionLabel" type="Label" parent="Container/DirectionBox/HBoxContainer"] +material = ExtResource( 4 ) +margin_right = 94.0 +margin_bottom = 18.0 mouse_filter = 1 theme = ExtResource( 3 ) text = "Ship direction" +[node name="CurrentDirection" type="Label" parent="Container/DirectionBox/HBoxContainer"] +material = ExtResource( 4 ) +margin_left = 98.0 +margin_right = 98.0 +margin_bottom = 18.0 +mouse_filter = 1 +theme = ExtResource( 3 ) +custom_colors/font_color = Color( 0.494118, 0.52549, 0.737255, 1 ) + [node name="HSlider" type="HSlider" parent="Container/DirectionBox"] material = ExtResource( 4 ) -margin_top = 25.0 +margin_top = 28.0 margin_right = 180.0 -margin_bottom = 41.0 +margin_bottom = 44.0 mouse_filter = 1 max_value = 360.0 tick_count = 18 diff --git a/Actors/Objects/Door/Door.gd b/Actors/Objects/Door/Door.gd index da5ab79..6ba2bf7 100644 --- a/Actors/Objects/Door/Door.gd +++ b/Actors/Objects/Door/Door.gd @@ -28,14 +28,16 @@ func _animation_finished(): # Disable collider collision_layer = 16 collision_mask = 16 + emit_signal("changed", true) # Start timer for auto-close $Timer.start() else: # Enable collider collision_mask = 1 collision_layer = 1 + emit_signal("changed", false) -func _input_event(viewport, event, shape_idx): +func _input_event(_viewport, event, _shape_idx): # Check if we clicked the item if event is InputEventMouseButton and event.pressed: # Must be in activation range diff --git a/Actors/Objects/Engine/Engine.gd b/Actors/Objects/Engine/Engine.gd index 3d4d608..5326b5c 100644 --- a/Actors/Objects/Engine/Engine.gd +++ b/Actors/Objects/Engine/Engine.gd @@ -47,7 +47,7 @@ func refresh_sprite(): $ActivationRange.rotation = rot -func _input_event(viewport, event, shape_idx): +func _input_event(_viewport, event, _shape_idx): if Engine.editor_hint: return if event is InputEventMouseButton and event.pressed: diff --git a/Actors/Objects/Lightbulb/Lightbulb.gd b/Actors/Objects/Lightbulb/Lightbulb.gd index e4c75c4..91bfc59 100644 --- a/Actors/Objects/Lightbulb/Lightbulb.gd +++ b/Actors/Objects/Lightbulb/Lightbulb.gd @@ -46,7 +46,7 @@ func refresh_sprite(): $ActivationRange.rotation = rot -func _input_event(viewport, event, shape_idx): +func _input_event(_viewport, event, _shape_idx): if Engine.editor_hint: return if event is InputEventMouseButton and event.pressed: diff --git a/Actors/Objects/PowerStorage/PowerStorage.gd b/Actors/Objects/PowerStorage/PowerStorage.gd new file mode 100644 index 0000000..ab29213 --- /dev/null +++ b/Actors/Objects/PowerStorage/PowerStorage.gd @@ -0,0 +1,3 @@ +extends StaticBody2D + +class_name GameObjectPowerStorage diff --git a/Actors/Objects/PowerStorage/PowerStorage.tscn b/Actors/Objects/PowerStorage/PowerStorage.tscn new file mode 100644 index 0000000..498bf14 --- /dev/null +++ b/Actors/Objects/PowerStorage/PowerStorage.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Actors/Objects/PowerStorage/PowerStorage.gd" type="Script" id=1] +[ext_resource path="res://Graphics/tgstation/smes.png" type="Texture" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 16, 16 ) + +[node name="StaticBody2D" type="StaticBody2D"] +script = ExtResource( 1 ) + +[node name="smes" type="Sprite" parent="."] +texture = ExtResource( 2 ) +centered = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 16, 16 ) +shape = SubResource( 1 ) diff --git a/Actors/Player/Player.gd b/Actors/Player/Player.gd index 1142796..732b6c4 100644 --- a/Actors/Player/Player.gd +++ b/Actors/Player/Player.gd @@ -11,8 +11,7 @@ var grip = 1.0 var stamina = MAX_STAMINA var speed_boost = 0 -export(NodePath) var mapNode -onready var map = get_node(mapNode) as GameMap +onready var world = $"/root/scene/world" as GameWorld export var is_controlled = false setget set_is_controlled @@ -50,11 +49,12 @@ func _physics_process(delta): velocity = move_and_slide(velocity) # Check what tile I'm on - grip = 0.0 - for tilemap in map.tilemaps: - var cell = tilemap.get_cellv(tilemap.world_to_map(transform.origin)) - if cell >= 0: - grip = 1.0 + if world.map != null: + grip = 0.0 + for tilemap in world.map.tilemaps: + var cell = tilemap.get_cellv(tilemap.world_to_map(transform.origin)) + if cell >= 0: + grip = 1.0 func set_is_controlled(val): is_controlled = val diff --git a/Graphics/tgstation/smes.png b/Graphics/tgstation/smes.png new file mode 100644 index 0000000000000000000000000000000000000000..6c2ad3d7db6199a08ef105fc37ba9af28dc18be7 GIT binary patch literal 908 zcmV;719SX|P)e;SP1oSg+z%+#W=S_%_R13b!5Z)H}qJCh;V;+V=&qRi=xJi-pGhe*ev}i;IgGWMN?; zK3=U>(G0^F`Mw_y+}zx-w6v6K7z9BfK)GDb1?u&BtgfyCQKOb+sW+j@IB8y~R8pPD zg57SHAP7d}u6Bxd8osUrF8Vc5{oV#`5Y&#d`oq?E@gS7a&?r z*L8D?0XUBH#<17x0i^N=uq-PAFbo42UoKe?70i2*rYd83l|4K>L;&q}8-SyuBPB={ zW)ex$q;a#^WNvPb{r!CaYPDK)6-e5HgM$=d5+qr0QYAaqG>yZ~TBp;&w(U{5 zT*kI-V7%OymzPtUszP<*a(P)tL1DF>= zXpKfA6@gqb3G(vtg6q1}>-CAc_B;>AaVV8a=(_&72mnf@67_l=(=;ankaMJF62V6` zlL(Uf`t2)JfG!OG8FGJr55U^@H2{WUm^yzZ5v245{`?95eHkAzO%s~=Q)U{$U%!Aq zfL{r7VEAMB=3H50rV;S(>))$n1mD-92*mLJjzA&PG>a0LZ3KU3I+PLo7=ADUIq=?% z$n(5{9@FwXkLBg%!W+@k)6*EhaU1}I5Vj0_xzVAny@U?R-`5h=v48!oWAz6)k0V-12JWvpo$LI`bVXNU9i^C*I>k|364;rl+8WlaSj=SWk4R;v{o iODO?VAfHju=lO3w%1OS%WFQ*=0000