diff --git a/Scenes/Actors/teleporter.tscn b/Scenes/Actors/teleporter.tscn index bd750507..5f6e2ead 100644 --- a/Scenes/Actors/teleporter.tscn +++ b/Scenes/Actors/teleporter.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://byms2dhliyux0"] +[gd_scene load_steps=8 format=3 uid="uid://byms2dhliyux0"] [ext_resource type="Script" uid="uid://c1q7esgfnbvsf" path="res://Scripts/Activables/Teleporter.cs" id="1_juavy"] [ext_resource type="SpriteFrames" uid="uid://w4jlaryen3we" path="res://Resources/Sprites/teleporter.tres" id="2_k58t7"] [ext_resource type="AudioStream" uid="uid://c4uxtkynonomm" path="res://SFX/teleporter_start.wav" id="3_ox1iw"] [ext_resource type="AudioStream" uid="uid://cq1880lc1iwsa" path="res://SFX/teleporter_end.wav" id="4_ildd2"] +[ext_resource type="Script" uid="uid://3jcfdfymcvxu" path="res://Scripts/Utils/TeleporterLinker.cs" id="5_ildd2"] [sub_resource type="CircleShape2D" id="CircleShape2D_kwj8m"] radius = 4.12311 @@ -34,7 +35,7 @@ animation = &"Teleporting" [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = ExtResource("2_k58t7") animation = &"Default" -frame_progress = 0.462812 +frame_progress = 0.620066 [node name="Particles" type="GPUParticles2D" parent="."] z_index = 2 @@ -53,4 +54,10 @@ process_mode = 3 stream = ExtResource("4_ildd2") max_distance = 100.0 +[node name="Visualizer" type="Node2D" parent="."] +z_index = 15 +z_as_relative = false +script = ExtResource("5_ildd2") +Color = Color(0, 0, 1, 0.741176) + [connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Maps/TeleporterTest.tscn b/Scenes/Maps/TeleporterTest.tscn new file mode 100644 index 00000000..d80321e1 --- /dev/null +++ b/Scenes/Maps/TeleporterTest.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=2 format=3 uid="uid://74hy0x41gei7"] + +[ext_resource type="PackedScene" uid="uid://byms2dhliyux0" path="res://Scenes/Actors/teleporter.tscn" id="1_4vmoo"] + +[node name="Node2D" type="Node2D"] + +[node name="Teleporter" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("1_4vmoo")] +position = Vector2(104, 66) +Target = NodePath("../Teleporter2") + +[node name="Teleporter2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("1_4vmoo")] +position = Vector2(45, 41) +IsEnabled = true +Target = NodePath("../Teleporter") +metadata/_edit_group_ = true diff --git a/Scenes/test.tscn b/Scenes/test.tscn index 1d7d5358..ec2228bb 100644 --- a/Scenes/test.tscn +++ b/Scenes/test.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=144 format=4 uid="uid://bv451a8wgty4u"] +[gd_scene load_steps=145 format=4 uid="uid://bv451a8wgty4u"] [ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"] [ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"] @@ -64,6 +64,7 @@ [ext_resource type="PackedScene" uid="uid://b0k2grrc8xp1l" path="res://Scenes/Props/BigTank.tscn" id="45_5qg27"] [ext_resource type="Script" uid="uid://bwox5lmgiijcs" path="res://Scripts/Resources/Events/ActivateEvent.cs" id="45_emjoj"] [ext_resource type="Script" uid="uid://b5fesrd4lv8t1" path="res://Scripts/Resources/Events/EventResource.cs" id="46_0bqta"] +[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="46_cxj4w"] [ext_resource type="Script" uid="uid://ddv26x2qilprb" path="res://Scripts/Resources/Events/DialogueStartEvent.cs" id="46_i0omr"] [ext_resource type="PackedScene" uid="uid://cqrkisw6jg24w" path="res://Scenes/Props/MainFrame1.tscn" id="46_ny2s2"] [ext_resource type="PackedScene" uid="uid://cdti0hnbs3e63" path="res://Scenes/Actors/RoamingSusan.tscn" id="47_u1ve6"] @@ -148,7 +149,7 @@ DamageType = 0 OverrideControllable = false Controllable = false OverrideCreationModifier = false -TimeModifiers = [] +TimeModifiers = Array[ExtResource("46_cxj4w")]([]) WaitForCompletion = true metadata/_custom_type_script = "uid://c0ndqalsc4jve" @@ -1124,7 +1125,7 @@ position = Vector2(-2000, -736) [node name="ControlPad8" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")] position = Vector2(-2027, -735) Targets = [NodePath("../HorizontalForceField")] -Requirements = [ExtResource("84_ma1ta")] +Requirements = Array[ExtResource("6_8tdlb")]([ExtResource("84_ma1ta")]) [node name="Ammo6" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")] position = Vector2(-872, -220) diff --git a/Scripts/Activables/Teleporter.cs b/Scripts/Activables/Teleporter.cs index 9083cf8e..ce293169 100644 --- a/Scripts/Activables/Teleporter.cs +++ b/Scripts/Activables/Teleporter.cs @@ -8,6 +8,7 @@ using GTweensGodot.Extensions; namespace Cirno.Scripts.Activables; +[Tool] public partial class Teleporter : Activable { [Export] @@ -41,30 +42,25 @@ public partial class Teleporter : Activable public override void _Ready() { - _particles = GetNode("./Particles"); _animatedSprite = GetNode("AnimatedSprite2D"); - + _animatedSprite.Play(IsEnabled ? "Active" : "Default"); + if (Engine.IsEditorHint()) return; + + _particles = GetNode("./Particles"); + IsPrimed = true; _particles.Emitting = false; _particleTimer = 0; this.Visible = !Invisible; - - if (IsEnabled) - { - _animatedSprite.Play("Active"); - } - else - { - _animatedSprite.Play("Default"); - } - + _teleportStartSound = GetNodeOrNull("TeleportStart"); _teleportEndSound = GetNodeOrNull("TeleportEnd"); } public override void _Process(double delta) { + if (Engine.IsEditorHint()) return; if (!_particles.Emitting) return; _particleTimer += delta; diff --git a/Scripts/Utils/TeleporterLinker.cs b/Scripts/Utils/TeleporterLinker.cs new file mode 100644 index 00000000..c3445da8 --- /dev/null +++ b/Scripts/Utils/TeleporterLinker.cs @@ -0,0 +1,41 @@ +using Cirno.Scripts.Activables; +using Godot; + +namespace Cirno.Scripts.Utils; + +[Tool] +public partial class TeleporterLinker : Node2D +{ + private Teleporter _teleporter; + + [Export] public Color Color { get; set; } = Colors.Blue; + + public override void _Ready() + { + _teleporter = GetParentOrNull(); + } + + public override void _Draw() + { + if (!Engine.IsEditorHint()) + return; + if (_teleporter is null) return; + if (!_teleporter.IsEnabled) return; + if (_teleporter.Target is null) return; + + Vector2 start = _teleporter.GlobalPosition; + Vector2 end = _teleporter.Target.GlobalPosition; + + DrawLine(ToLocal(start), ToLocal(end), Color, 2.0f); + } + + public override void _Process(double delta) + { + if (Engine.IsEditorHint()) + { + QueueRedraw(); + } + } + + +} \ No newline at end of file diff --git a/Scripts/Utils/TeleporterLinker.cs.uid b/Scripts/Utils/TeleporterLinker.cs.uid new file mode 100644 index 00000000..39163360 --- /dev/null +++ b/Scripts/Utils/TeleporterLinker.cs.uid @@ -0,0 +1 @@ +uid://3jcfdfymcvxu