WIP electrical work

This commit is contained in:
Hamcha 2020-07-08 14:30:46 +02:00
parent 6b25359a38
commit 04eb4846e8
21 changed files with 325 additions and 59 deletions

View file

@ -0,0 +1,10 @@
extends Node
class_name PowerManager
signal power_connected()
signal power_disconnected()
var wired = false
const DEBUG = true

View file

@ -0,0 +1,53 @@
tool
extends Area2D
enum Direction { LEFT, RIGHT, UP, DOWN }
enum Flow { SOURCE, SINK }
export(Direction) var direction = Direction.DOWN setget set_direction
export(Array, NodePath) var connections = []
export(Color) var source_color
export(Color) var sink_color
export(Flow) var flow = Flow.SINK setget set_flow
var ready = false
func _ready():
ready = true
$socket.material = $socket.material.duplicate()
refresh_sprite()
func set_direction(dir):
direction = dir
if ready:
refresh_sprite()
func set_flow(val):
flow = val
if ready:
refresh_sprite()
func refresh_sprite():
var rot = 0
match direction:
Direction.DOWN:
$socket.region_rect.position = Vector2(0, 0)
rot = 0
Direction.UP:
$socket.region_rect.position = Vector2(32, 0)
rot = PI
Direction.LEFT:
$socket.region_rect.position = Vector2(32, 32)
rot = PI/2
Direction.RIGHT:
$socket.region_rect.position = Vector2(0, 32)
rot = -PI/2
match flow:
Flow.SOURCE:
$socket.material.set_shader_param("cable_color", source_color)
Flow.SINK:
$socket.material.set_shader_param("cable_color", sink_color)

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Graphics/tgstation/socket.png" type="Texture" id=1]
[ext_resource path="res://Actors/Objects/ElectricSocket/ElectricSocket.gd" type="Script" id=2]
[sub_resource type="Shader" id=4]
code = "shader_type canvas_item;
render_mode blend_mix;
uniform vec4 cable_color: hint_color;
void fragment() {
vec4 col = texture(TEXTURE, UV);
if (col.r/col.g > 2.) {
col.rgb = cable_color.rgb * length(col.rgb);
}
COLOR = col;
}"
custom_defines = ""
[sub_resource type="ShaderMaterial" id=5]
shader = SubResource( 4 )
shader_param/cable_color = Color( 0.0823529, 0.937255, 0.27451, 1 )
[sub_resource type="CircleShape2D" id=6]
radius = 12.0
[node name="ElectricSocket" type="Area2D"]
collision_layer = 4
collision_mask = 2147483652
script = ExtResource( 2 )
direction = 1
source_color = Color( 0.937255, 0.0823529, 0.0823529, 1 )
sink_color = Color( 0.0901961, 0.533333, 0.960784, 1 )
[node name="socket" type="Sprite" parent="."]
material = SubResource( 5 )
texture = ExtResource( 1 )
centered = false
region_enabled = true
region_rect = Rect2( 0, 32, 32, 32 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 16, 16 )
shape = SubResource( 6 )

View file

@ -2,13 +2,23 @@ extends StaticBody2D
class_name GameObjectPowerStorage class_name GameObjectPowerStorage
const MAX_CHARGE = 5000.0
var open = false var open = false
var attached = true
onready var activationRange = $ActivationRange as ActivationRange onready var activationRange = $ActivationRange as ActivationRange
var current_charge = MAX_CHARGE
func _ready(): func _ready():
if not Engine.editor_hint: if not Engine.editor_hint:
activationRange.visible = true activationRange.visible = true
func _physics_process(delta):
if $PowerManager.wired:
if $PowerManager.DEBUG:
update()
func _input(event): func _input(event):
if event is InputEventMouseButton and event.pressed and not is_inside and open: if event is InputEventMouseButton and event.pressed and not is_inside and open:
open = false open = false
@ -36,3 +46,13 @@ func _force_close_ui():
if open: if open:
open = false open = false
$UIAnimation.play("fadeout") $UIAnimation.play("fadeout")
func _draw():
if $PowerManager.DEBUG:
var charge_px = int(current_charge / MAX_CHARGE * 32)
var charge_color = Color.greenyellow
if charge_px < 20:
charge_color = Color.yellow
if charge_px < 10:
charge_color = Color.red
draw_rect(Rect2(32, 32-charge_px, 4, charge_px), charge_color)

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=9 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://Actors/Objects/PowerStorage/PowerStorage.gd" type="Script" id=1] [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] [ext_resource path="res://Graphics/tgstation/smes.png" type="Texture" id=2]
[ext_resource path="res://Actors/Components/ActivationRange.gd" type="Script" id=3] [ext_resource path="res://Actors/Components/ActivationRange.gd" type="Script" id=3]
[ext_resource path="res://Actors/Objects/PowerStorage/UI/PowerUI.tscn" type="PackedScene" id=4] [ext_resource path="res://Actors/Objects/PowerStorage/UI/PowerUI.tscn" type="PackedScene" id=4]
[ext_resource path="res://Actors/Components/PowerManager.gd" type="Script" id=5]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 ) extents = Vector2( 16, 16 )
@ -12,7 +13,7 @@ extents = Vector2( 16, 16 )
length = 0.2 length = 0.2
step = 0.05 step = 0.05
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/path = NodePath("Control:modulate") tracks/0/path = NodePath("../StaticBody2D/Control:modulate")
tracks/0/interp = 1 tracks/0/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/imported = false tracks/0/imported = false
@ -24,7 +25,7 @@ tracks/0/keys = {
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] "values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
} }
tracks/1/type = "bezier" tracks/1/type = "bezier"
tracks/1/path = NodePath("Control:position:y") tracks/1/path = NodePath("../StaticBody2D/Control:position:y")
tracks/1/interp = 1 tracks/1/interp = 1
tracks/1/loop_wrap = true tracks/1/loop_wrap = true
tracks/1/imported = false tracks/1/imported = false
@ -37,7 +38,7 @@ tracks/1/keys = {
[sub_resource type="Animation" id=3] [sub_resource type="Animation" id=3]
length = 0.2 length = 0.2
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/path = NodePath("Control:modulate") tracks/0/path = NodePath("../StaticBody2D/Control:modulate")
tracks/0/interp = 1 tracks/0/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/imported = false tracks/0/imported = false
@ -49,7 +50,7 @@ tracks/0/keys = {
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] "values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
} }
tracks/1/type = "bezier" tracks/1/type = "bezier"
tracks/1/path = NodePath("Control:position:y") tracks/1/path = NodePath("../StaticBody2D/Control:position:y")
tracks/1/interp = 1 tracks/1/interp = 1
tracks/1/loop_wrap = true tracks/1/loop_wrap = true
tracks/1/imported = false tracks/1/imported = false
@ -59,7 +60,7 @@ tracks/1/keys = {
"times": PoolRealArray( 0, 0.2 ) "times": PoolRealArray( 0, 0.2 )
} }
[sub_resource type="CircleShape2D" id=4] [sub_resource type="CircleShape2D" id=5]
radius = 56.0 radius = 56.0
[node name="StaticBody2D" type="StaticBody2D"] [node name="StaticBody2D" type="StaticBody2D"]
@ -78,6 +79,9 @@ centered = false
anims/fadein = SubResource( 2 ) anims/fadein = SubResource( 2 )
anims/fadeout = SubResource( 3 ) anims/fadeout = SubResource( 3 )
[node name="PowerManager" type="Node" parent="."]
script = ExtResource( 5 )
[node name="Control" type="Node2D" parent="."] [node name="Control" type="Node2D" parent="."]
position = Vector2( 16, 0 ) position = Vector2( 16, 0 )
z_index = 999 z_index = 999
@ -96,7 +100,7 @@ position = Vector2( 16, 16 )
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ActivationRange"] [node name="CollisionShape2D" type="CollisionShape2D" parent="ActivationRange"]
shape = SubResource( 4 ) shape = SubResource( 5 )
[connection signal="mouse_entered" from="Control/PowerUI" to="." method="_ui_focus_changed" binds= [ true ]] [connection signal="mouse_entered" from="Control/PowerUI" to="." method="_ui_focus_changed" binds= [ true ]]
[connection signal="mouse_exited" from="Control/PowerUI" to="." method="_ui_focus_changed" binds= [ false ]] [connection signal="mouse_exited" from="Control/PowerUI" to="." method="_ui_focus_changed" binds= [ false ]]
[connection signal="player_left" from="ActivationRange" to="." method="_force_close_ui"] [connection signal="player_left" from="ActivationRange" to="." method="_force_close_ui"]

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://Graphics/tgstation/scanner.png" type="Texture" id=1] [ext_resource path="res://Graphics/tgstation/scanner.png" type="Texture" id=1]
[ext_resource path="res://Actors/Objects/Scanner/Scanner.gd" type="Script" id=2] [ext_resource path="res://Actors/Objects/Scanner/Scanner.gd" type="Script" id=2]
[ext_resource path="res://Actors/Components/PowerManager.gd" type="Script" id=3]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 ) extents = Vector2( 16, 16 )
@ -17,3 +18,6 @@ shape = SubResource( 1 )
position = Vector2( -1, 0 ) position = Vector2( -1, 0 )
texture = ExtResource( 1 ) texture = ExtResource( 1 )
centered = false centered = false
[node name="PowerManager" type="Node" parent="."]
script = ExtResource( 3 )

View file

@ -0,0 +1,25 @@
extends Area2D
class_name ProbeElectric
const DEBUG = true
const center = Vector2.ONE * 16
var neighbours = []
func _physics_process(delta):
if DEBUG:
update()
func _draw():
if DEBUG:
draw_circle(center, 4, Color.cyan)
for neighbour in neighbours:
var delta = (neighbour.global_position - global_position) / global_scale
draw_line(center, delta + center, Color.cyan, 2)
func _got_neighbour(area: Area2D):
if area == self:
return
neighbours.push_back(area)

View file

@ -0,0 +1,36 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Actors/Systems/Electricity/ElectricProbe.gd" type="Script" id=1]
[sub_resource type="CircleShape2D" id=1]
radius = 12.0
[sub_resource type="SegmentShape2D" id=2]
a = Vector2( 16, -16 )
b = Vector2( 16, 48 )
[sub_resource type="SegmentShape2D" id=3]
a = Vector2( -16, 16 )
b = Vector2( 48, 16 )
[node name="ElProbe" type="Area2D"]
collision_layer = 4
collision_mask = 4
script = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 16, 16 )
shape = SubResource( 1 )
[node name="NeighbourCheck" type="Area2D" parent="."]
input_pickable = false
monitorable = false
collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="NeighbourCheck"]
shape = SubResource( 2 )
[node name="CollisionShape2D2" type="CollisionShape2D" parent="NeighbourCheck"]
shape = SubResource( 3 )
[connection signal="area_entered" from="NeighbourCheck" to="." method="_got_neighbour"]

View file

@ -0,0 +1 @@
extends Node

View file

@ -3,7 +3,7 @@
[ext_resource path="res://Graphics/tgstation/wires-l2.png" type="Texture" id=1] [ext_resource path="res://Graphics/tgstation/wires-l2.png" type="Texture" id=1]
[resource] [resource]
0/name = "wires-l2.png 0" 0/name = "Wire"
0/texture = ExtResource( 1 ) 0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 ) 0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 ) 0/modulate = Color( 1, 1, 1, 1 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/socket.png-6a3c65f9b84aa2e36705290607e8f31f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/tgstation/socket.png"
dest_files=[ "res://.import/socket.png-6a3c65f9b84aa2e36705290607e8f31f.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

View file

@ -20,7 +20,7 @@ compress/hdr_mode=0
compress/bptc_ldr=0 compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 flags/repeat=0
flags/filter=true flags/filter=false
flags/mipmaps=false flags/mipmaps=false
flags/anisotropic=false flags/anisotropic=false
flags/srgb=2 flags/srgb=2

View file

@ -20,7 +20,6 @@ map_path = NodePath("runtime")
[node name="runtime" parent="world" instance=ExtResource( 7 )] [node name="runtime" parent="world" instance=ExtResource( 7 )]
[node name="odyssey" parent="world" instance=ExtResource( 1 )] [node name="odyssey" parent="world" instance=ExtResource( 1 )]
visible = false
[node name="player" parent="world" instance=ExtResource( 2 )] [node name="player" parent="world" instance=ExtResource( 2 )]
position = Vector2( 206.017, 250.966 ) position = Vector2( 206.017, 250.966 )

View file

@ -13,26 +13,29 @@ const SPEED_EASE = 0.5
const DIRECTION_EASE = 0.5 const DIRECTION_EASE = 0.5
const EPSILON = 0.01 const EPSILON = 0.01
var tilemaps = [] const ProbeElectricity = preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
onready var tilemaps = [ $base, $cables, $floor, $walls ]
export var unlit = false setget set_unlit export var unlit = false setget set_unlit
onready var darkness = $darkness 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() $editor.queue_free()
set_unlit(false) set_unlit(false)
func set_unlit(val): # Electricity setup
unlit = val make_electric_probes($cables, "Wire")
if darkness:
darkness.visible = not val
func _process(delta): func _process(delta: float):
if Engine.editor_hint: if Engine.editor_hint:
return return
# Ease ship speed/direction changes
if abs(ship_direction - current_ship_direction) < EPSILON: if abs(ship_direction - current_ship_direction) < EPSILON:
current_ship_direction = ship_direction current_ship_direction = ship_direction
else: else:
@ -45,9 +48,28 @@ func _process(delta):
$deepspace.rotation = current_ship_direction-PI/2 $deepspace.rotation = current_ship_direction-PI/2
$deepspace.region_rect.position += Vector2(sin(current_ship_direction), cos(current_ship_direction)) * current_ship_speed * delta $deepspace.region_rect.position += Vector2(sin(current_ship_direction), cos(current_ship_direction)) * current_ship_speed * delta
# Lighting
func set_unlit(val: bool):
unlit = val
if darkness:
darkness.visible = not val
# Engine related functions
func set_engine_strength(val: float): 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
# 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)

File diff suppressed because one or more lines are too long

View file

@ -1,10 +1,4 @@
extends GameMap extends GameMap
func _ready(): func _ready():
tilemaps = [
$base,
$cables,
$floor,
$walls
]
set_unlit(true) set_unlit(true)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=2] [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/walls.tres" type="TileSet" id=1]
[ext_resource path="res://Graphics/tgstation/1x1.tres" type="TileSet" id=2] [ext_resource path="res://Graphics/tgstation/1x1.tres" type="TileSet" id=2]
@ -12,12 +12,12 @@
[ext_resource path="res://Actors/Objects/Engine/Engine.tscn" type="PackedScene" id=10] [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://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/PowerStorage/PowerStorage.tscn" type="PackedScene" id=12]
[ext_resource path="res://Actors/Objects/ElectricSocket/ElectricSocket.tscn" type="PackedScene" id=13]
[sub_resource type="CanvasItemMaterial" id=1] [sub_resource type="CanvasItemMaterial" id=1]
light_mode = 1 light_mode = 1
[node name="map" type="Node2D"] [node name="map" type="Node2D"]
position = Vector2( -1, 0 )
script = ExtResource( 5 ) script = ExtResource( 5 )
[node name="darkness" type="CanvasModulate" parent="."] [node name="darkness" type="CanvasModulate" parent="."]
@ -43,19 +43,14 @@ cell_quadrant_size = 32
occluder_light_mask = -2147483647 occluder_light_mask = -2147483647
format = 1 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 ) 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 )
script = ExtResource( 3 )
extended_tilemap_node = NodePath("../1x1")
[node name="cables" type="TileMap" parent="."] [node name="cables" type="TileMap" parent="."]
position = Vector2( -3, 0 )
tile_set = ExtResource( 4 ) tile_set = ExtResource( 4 )
cell_size = Vector2( 32, 32 ) cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32 cell_quadrant_size = 32
occluder_light_mask = -2147483647 occluder_light_mask = -2147483647
format = 1 format = 1
tile_data = PoolIntArray( 524286, 0, 131072, 524287, 0, 65536, 458752, 0, 65536, 458753, 0, 65536, 458754, 0, 65536, 458755, 0, 196608, 524291, 0, 65539, 655355, 0, 131073, 589827, 0, 65539, 720891, 0, 65539, 655363, 0, 131075, 786427, 0, 65538, 786428, 0, 65536, 786429, 0, 262144 ) tile_data = PoolIntArray( 393214, 0, 327681, 393215, 0, 262145, 327680, 0, 458752, 458749, 0, 65537, 458750, 0, 262150, 458751, 0, 458754, 393216, 0, 393218, 524284, 0, 327681, 524285, 0, 131078, 524287, 0, 262151, 458752, 0, 458755, 458755, 0, 131072, 458756, 0, 0, 589820, 0, 262151, 589821, 0, 6, 589822, 0, 1, 589823, 0, 196611, 655355, 0, 131072, 655356, 0, 131074, 655358, 0, 65539, 589828, 0, 131073, 720892, 0, 65538, 720893, 0, 1, 720894, 0, 2, 720895, 0, 262144, 655363, 0, 131072, 655364, 0, 2, 655365, 0, 65536, 655366, 0, 65536, 655367, 0, 1, 655368, 0, 262144, 786429, 0, 131075, 720903, 0, 131075 )
script = ExtResource( 3 )
extended_tilemap_node = NodePath("../1x1")
[node name="floor" type="TileMap" parent="."] [node name="floor" type="TileMap" parent="."]
tile_set = ExtResource( 9 ) tile_set = ExtResource( 9 )
@ -63,8 +58,6 @@ cell_size = Vector2( 32, 32 )
cell_quadrant_size = 32 cell_quadrant_size = 32
occluder_light_mask = -2147483647 occluder_light_mask = -2147483647
format = 1 format = 1
script = ExtResource( 3 )
extended_tilemap_node = NodePath("../1x1")
[node name="walls" type="TileMap" parent="."] [node name="walls" type="TileMap" parent="."]
tile_set = ExtResource( 1 ) tile_set = ExtResource( 1 )
@ -106,37 +99,50 @@ __meta__ = {
} }
[node name="Computer" parent="objects" instance=ExtResource( 6 )] [node name="Computer" parent="objects" instance=ExtResource( 6 )]
position = Vector2( -32, 224 ) position = Vector2( -64, 128 )
[node name="Computer2" parent="objects" instance=ExtResource( 6 )] [node name="Computer2" parent="objects" instance=ExtResource( 6 )]
position = Vector2( 0, 224 ) position = Vector2( -32, 128 )
computer_type = 1 computer_type = 1
[node name="Computer3" parent="objects" instance=ExtResource( 6 )] [node name="Computer3" parent="objects" instance=ExtResource( 6 )]
position = Vector2( 32, 224 ) position = Vector2( 0, 128 )
computer_type = 2 computer_type = 2
[node name="Computer4" parent="objects" instance=ExtResource( 6 )] [node name="Computer4" parent="objects" instance=ExtResource( 6 )]
position = Vector2( 64, 224 ) position = Vector2( 32, 128 )
computer_type = 3 computer_type = 3
[node name="Computer5" parent="objects" instance=ExtResource( 6 )] [node name="Computer5" parent="objects" instance=ExtResource( 6 )]
position = Vector2( -64, 224 ) position = Vector2( -96, 128 )
computer_type = 4 computer_type = 4
[node name="Computer6" parent="objects" instance=ExtResource( 6 )] [node name="Computer6" parent="objects" instance=ExtResource( 6 )]
position = Vector2( -96, 224 ) position = Vector2( -128, 128 )
computer_type = 5 computer_type = 5
[node name="StaticBody2D2" parent="objects" instance=ExtResource( 12 )]
position = Vector2( 193, 128 )
[node name="SMES1" parent="objects" instance=ExtResource( 12 )]
position = Vector2( 128, 256 )
[node name="Computer7" parent="objects" instance=ExtResource( 6 )] [node name="Computer7" parent="objects" instance=ExtResource( 6 )]
position = Vector2( 96, 224 ) position = Vector2( 64, 128 )
computer_type = 6 computer_type = 6
[node name="StaticBody2D" parent="objects/Computer7" instance=ExtResource( 12 )] [node name="Scanner" parent="objects" instance=ExtResource( 8 )]
position = Vector2( -255, 64 ) position = Vector2( 288, 320 )
[node name="StaticBody2D2" parent="objects/Computer7" instance=ExtResource( 12 )] [node name="ElectricSocket" parent="objects" instance=ExtResource( 13 )]
position = Vector2( 1, 96 ) position = Vector2( 128, 288 )
direction = 2
connections = [ NodePath("../SMES1") ]
flow = 0
[node name="ElectricSocket2" parent="objects" instance=ExtResource( 13 )]
position = Vector2( 256, 320 )
connections = [ NodePath("../Scanner") ]
[node name="lights" type="Node2D" parent="."] [node name="lights" type="Node2D" parent="."]
modulate = Color( 0.980392, 0.980392, 0.980392, 1 ) modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
@ -144,6 +150,3 @@ __meta__ = {
"_edit_group_": true, "_edit_group_": true,
"_edit_lock_": true "_edit_lock_": true
} }
[node name="StaticBody2D" parent="." instance=ExtResource( 8 )]
position = Vector2( -95, 352 )

View file

@ -3,6 +3,7 @@ extends TileMap
class_name MapTiles class_name MapTiles
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
@ -10,12 +11,13 @@ export var shadow_intensity = 0.2
onready var extended_tilemap = get_node(extended_tilemap_node) as TileMap onready var extended_tilemap = get_node(extended_tilemap_node) as TileMap
func _ready(): func _ready():
# Make occluders for FOV # Make occluders
make_occluders() make_occluders()
# Convert 2x2 tiles to 1x1 if possible # Convert 2x2 tiles to 1x1 if possible
convert_extended() convert_extended()
func convert_extended(): func convert_extended():
var extended = extended_tilemap.tile_set var extended = extended_tilemap.tile_set
for id in tile_set.get_tiles_ids(): for id in tile_set.get_tiles_ids():
@ -39,7 +41,9 @@ func convert_extended():
func make_occluders(): func make_occluders():
var occluder_ids = [] var occluder_ids = []
for occluder_name in occluders: for occluder_name in occluders:
occluder_ids.push_back(tile_set.find_tile_by_name(occluder_name)) var id = tile_set.find_tile_by_name(occluder_name)
if id >= 0:
occluder_ids.push_back(id)
for id in tile_set.get_tiles_ids(): for id in tile_set.get_tiles_ids():
if occluder_ids.find(id) < 0: if occluder_ids.find(id) < 0:
# Not an occluder, skip it # Not an occluder, skip it

View file

@ -10,4 +10,5 @@ onready var map = get_node(map_path) as GameMap
func _ready(): func _ready():
for tilemap in map.tilemaps: for tilemap in map.tilemaps:
if tilemap is MapTiles:
tilemap.set_occluder_origin(player) tilemap.set_occluder_origin(player)

View file

@ -74,6 +74,16 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://Scenes/Rendering/Occluder.gd" "path": "res://Scenes/Rendering/Occluder.gd"
}, { }, {
"base": "Node",
"class": "PowerManager",
"language": "GDScript",
"path": "res://Actors/Components/PowerManager.gd"
}, {
"base": "Area2D",
"class": "ProbeElectric",
"language": "GDScript",
"path": "res://Actors/Systems/Electricity/ElectricProbe.gd"
}, {
"base": "Reference", "base": "Reference",
"class": "UICommand", "class": "UICommand",
"language": "GDScript", "language": "GDScript",
@ -93,6 +103,8 @@ _global_script_class_icons={
"GameWorld": "", "GameWorld": "",
"MapTiles": "", "MapTiles": "",
"Occluder": "", "Occluder": "",
"PowerManager": "",
"ProbeElectric": "",
"UICommand": "" "UICommand": ""
} }
@ -152,6 +164,12 @@ sprint={
] ]
} }
[layer_names]
2d_physics/layer_1="Environment"
2d_physics/layer_2="Projectile"
2d_physics/layer_3="Electric"
[rendering] [rendering]
vram_compression/import_etc=true vram_compression/import_etc=true