From f65ef4b8f90fa556101ba46a816b3bae8f17471e Mon Sep 17 00:00:00 2001 From: Hamcha Date: Mon, 6 Jul 2020 18:41:30 +0200 Subject: [PATCH] Add doors! --- Actors/Objects/Door/Door.gd | 26 +++++++++ Actors/Objects/Door/Door.tscn | 56 ++++++++++++++++++++ Graphics/tgstation/objects.tres | 19 +++++++ Graphics/tgstation/opening-sheet.png | Bin 0 -> 3136 bytes Graphics/tgstation/opening-sheet.png.import | 34 ++++++++++++ Scenes/Maps/Objects.gd | 17 ++++++ Scenes/Maps/odyssey.tscn | 13 ++++- 7 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 Actors/Objects/Door/Door.gd create mode 100644 Actors/Objects/Door/Door.tscn create mode 100644 Graphics/tgstation/objects.tres create mode 100644 Graphics/tgstation/opening-sheet.png create mode 100644 Graphics/tgstation/opening-sheet.png.import create mode 100644 Scenes/Maps/Objects.gd diff --git a/Actors/Objects/Door/Door.gd b/Actors/Objects/Door/Door.gd new file mode 100644 index 0000000..198bdd1 --- /dev/null +++ b/Actors/Objects/Door/Door.gd @@ -0,0 +1,26 @@ +extends StaticBody2D + +signal changed(open) + +func set_open(open: bool): + if open: + $Sprite.play("open") + else: + $Sprite.play("close") + +func _animation_finished(): + if $Sprite.animation == "open": + print("Door opened") + # Disable collider + collision_layer = 2 + collision_mask = 2 + else: + print("Door closed") + # Enable collider + collision_mask = 1 + collision_layer = 1 + +func _input_event(viewport, event, shape_idx): + if event is InputEventMouseButton and event.pressed: + set_open($Sprite.animation == "close") + diff --git a/Actors/Objects/Door/Door.tscn b/Actors/Objects/Door/Door.tscn new file mode 100644 index 0000000..e0fbb5b --- /dev/null +++ b/Actors/Objects/Door/Door.tscn @@ -0,0 +1,56 @@ +[gd_scene load_steps=10 format=2] + +[ext_resource path="res://Actors/Objects/Door/Door.gd" type="Script" id=1] +[ext_resource path="res://Graphics/tgstation/opening-sheet.png" type="Texture" id=2] + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 2 ) +region = Rect2( 0, 64, 32, 32 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 2 ) +region = Rect2( 32, 32, 32, 32 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 2 ) +region = Rect2( 0, 32, 32, 32 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 2 ) +region = Rect2( 32, 0, 32, 32 ) + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 2 ) +region = Rect2( 0, 0, 32, 32 ) + +[sub_resource type="SpriteFrames" id=6] +animations = [ { +"frames": [ SubResource( 5 ), SubResource( 4 ), SubResource( 3 ), SubResource( 2 ), SubResource( 1 ) ], +"loop": false, +"name": "close", +"speed": 20.0 +}, { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ], +"loop": false, +"name": "open", +"speed": 20.0 +} ] + +[sub_resource type="RectangleShape2D" id=7] +extents = Vector2( 16, 16 ) + +[node name="Node2D" type="StaticBody2D"] +input_pickable = true +script = ExtResource( 1 ) + +[node name="Sprite" type="AnimatedSprite" parent="."] +frames = SubResource( 6 ) +animation = "close" +frame = 4 +playing = true +centered = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 16, 16 ) +shape = SubResource( 7 ) +[connection signal="animation_finished" from="Sprite" to="." method="_animation_finished"] diff --git a/Graphics/tgstation/objects.tres b/Graphics/tgstation/objects.tres new file mode 100644 index 0000000..4d53635 --- /dev/null +++ b/Graphics/tgstation/objects.tres @@ -0,0 +1,19 @@ +[gd_resource type="TileSet" load_steps=2 format=2] + +[ext_resource path="res://Graphics/tgstation/opening-sheet.png" type="Texture" id=3] + +[resource] +3/name = "Door" +3/texture = ExtResource( 3 ) +3/tex_offset = Vector2( 0, 0 ) +3/modulate = Color( 1, 1, 1, 1 ) +3/region = Rect2( 0, 0, 32, 32 ) +3/tile_mode = 0 +3/occluder_offset = Vector2( 0, 0 ) +3/navigation_offset = Vector2( 0, 0 ) +3/shape_offset = Vector2( 0, 0 ) +3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) +3/shape_one_way = false +3/shape_one_way_margin = 0.0 +3/shapes = [ ] +3/z_index = 0 diff --git a/Graphics/tgstation/opening-sheet.png b/Graphics/tgstation/opening-sheet.png new file mode 100644 index 0000000000000000000000000000000000000000..bc60b6dac604b8e4413600a9654d009923cfdc32 GIT binary patch literal 3136 zcmV-G48QYPx=`bk7VRCt{2TupBq#~FUO+!eo8rD$1_>Z zBmw}4#bU_k^8f&j!=1qtS5U7fi~MPW&9l0RV=FhoLA60DuMdJ3l== z4FJgHa+sT&!;we?N5{rABhQ{bMX6lI)vH%=?#vln`|dl;&(8w@Zrr%x_zbbXyu6Hf zJdS)mj}s?OARG?k&Ye5>;DZmq^E`HUcQG+BfuW%x)MXh`rGk7ukIB(d{AYO?+uPeM z{DL50Zf*`kLqk|wTSGh^2OkPy$mc`7UdP791{j8cBuQ9WTEf}0XCaCrJRg7ju}V50 z3aZzhPJE(1K;fMS85sSqT2n4>7BniXA!(ds~w0>o43!#w_ z0Klzpzs0-f&kIKWTrQVPBoeOpcj|R)S1RCn9_-4>3ML~FUFUh8htKEJ{+4AKk|Y5D z0)c=l5<46IkrB+i^%k=i`;>-D0vy$yDHdKw|G7vyW>d0zWIX~g4kNRos=AONSC!N~>ys6HR2r>8MA zGz2~nz}niH)^Jf20RU4|Q%xr{8VCo2P!z?L185t5zaMw+-UR@J!(q({Q&UqIR#h;; zU=Zrwo1zCz<+`3FFIn=18If#xtYg48wI$mjFmdA`M2YmXlT0HV>TAc~@Z<|HSK zkBI5Tz)QvUB0W1)M*B9=TjDN%JQX z2_cb42*e2{{3*g8jYb8}?k)<2Lel}N&!>B9ZaNPDo12?%tLkj~d_LVs8asAOp!h92 z4?z2bI^<6g{;^}n1OQD33<_>monFH0^>*ffYPH(!wm3rG`(yxU6InOVkpl+t=IABW zYQNA4+IB#-TGd9t=;&zI8e#`ombDQO2n4hd&<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