mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-17 02:23:48 +00:00
Switch multitarget
This commit is contained in:
parent
8d1c0beadc
commit
a5dac0606c
3 changed files with 36 additions and 22 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=90 format=4 uid="uid://bv451a8wgty4u"]
|
[gd_scene load_steps=89 format=4 uid="uid://bv451a8wgty4u"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"]
|
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"]
|
||||||
|
|
@ -73,8 +73,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://bc054js8ep2b" path="res://Scenes/Actors/FairyGuard_New.tscn" id="73_cfpaq"]
|
[ext_resource type="PackedScene" uid="uid://bc054js8ep2b" path="res://Scenes/Actors/FairyGuard_New.tscn" id="73_cfpaq"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bdvj4cxnyr3w4" path="res://Scenes/Actors/Thermathron.tscn" id="73_ier4h"]
|
[ext_resource type="PackedScene" uid="uid://bdvj4cxnyr3w4" path="res://Scenes/Actors/Thermathron.tscn" id="73_ier4h"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dfat0erkvb513" path="res://Scenes/Actors/Fairy_New.tscn" id="73_s4x1s"]
|
[ext_resource type="PackedScene" uid="uid://dfat0erkvb513" path="res://Scenes/Actors/Fairy_New.tscn" id="73_s4x1s"]
|
||||||
[ext_resource type="Texture2D" uid="uid://m32iqs21np0v" path="res://Sprites/BlackPixel.png" id="74_ra850"]
|
[ext_resource type="PackedScene" uid="uid://c21m7w5ahpsd0" path="res://Scenes/Activable/Shroud.tscn" id="74_oaf68"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Activables/BlackCover.cs" id="75_jy7lo"]
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_6sau4"]
|
[sub_resource type="Resource" id="Resource_6sau4"]
|
||||||
script = ExtResource("7_l32kg")
|
script = ExtResource("7_l32kg")
|
||||||
|
|
@ -197,10 +196,12 @@ metadata/_edit_lock_ = true
|
||||||
[node name="HiddenProps" type="Node2D" parent="Factory Tilemaps"]
|
[node name="HiddenProps" type="Node2D" parent="Factory Tilemaps"]
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="ControlPad5" parent="Factory Tilemaps/HiddenProps" node_paths=PackedStringArray("Target") instance=ExtResource("12_hfkf1")]
|
[node name="ControlPad5" parent="Factory Tilemaps/HiddenProps" node_paths=PackedStringArray("Target", "Targets") instance=ExtResource("12_hfkf1")]
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
position = Vector2(-968, 162)
|
position = Vector2(-968, 162)
|
||||||
Target = NodePath("../../HorizontalDoor2")
|
Target = NodePath("../../HorizontalDoor2")
|
||||||
|
Targets = [NodePath("../../../Shroud")]
|
||||||
|
ActivationType = 5
|
||||||
|
|
||||||
[node name="Debug Room" type="Node2D" parent="Factory Tilemaps"]
|
[node name="Debug Room" type="Node2D" parent="Factory Tilemaps"]
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
@ -333,13 +334,13 @@ Target = NodePath("../Door_vertical")
|
||||||
position = Vector2(-1064, 165)
|
position = Vector2(-1064, 165)
|
||||||
Target = NodePath("../Door_vertical")
|
Target = NodePath("../Door_vertical")
|
||||||
|
|
||||||
[node name="ControlPad2" parent="Factory Tilemaps" node_paths=PackedStringArray("Target") instance=ExtResource("12_hfkf1")]
|
[node name="ControlPad2" parent="Factory Tilemaps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")]
|
||||||
position = Vector2(-824, 165)
|
position = Vector2(-824, 165)
|
||||||
Target = NodePath("../Door_vertical2")
|
Targets = [NodePath("../Door_vertical2")]
|
||||||
|
|
||||||
[node name="ControlPad4" parent="Factory Tilemaps" node_paths=PackedStringArray("Target") instance=ExtResource("12_hfkf1")]
|
[node name="ControlPad4" parent="Factory Tilemaps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")]
|
||||||
position = Vector2(-856, 167)
|
position = Vector2(-856, 167)
|
||||||
Target = NodePath("../Door_vertical2")
|
Targets = [NodePath("../Door_vertical2")]
|
||||||
|
|
||||||
[node name="Door_vertical" parent="Factory Tilemaps" instance=ExtResource("15_mgtvp")]
|
[node name="Door_vertical" parent="Factory Tilemaps" instance=ExtResource("15_mgtvp")]
|
||||||
position = Vector2(-1048, 184)
|
position = Vector2(-1048, 184)
|
||||||
|
|
@ -535,6 +536,15 @@ Target = NodePath("../Debug Room/HorizontalForceField")
|
||||||
[node name="VerticalDoor" parent="Factory Tilemaps" instance=ExtResource("15_mgtvp")]
|
[node name="VerticalDoor" parent="Factory Tilemaps" instance=ExtResource("15_mgtvp")]
|
||||||
position = Vector2(-1452, -247)
|
position = Vector2(-1452, -247)
|
||||||
|
|
||||||
|
[node name="Teleporter10" parent="Factory Tilemaps" node_paths=PackedStringArray("Target") instance=ExtResource("30_8fdby")]
|
||||||
|
position = Vector2(-815, -343)
|
||||||
|
IsEnabled = true
|
||||||
|
Target = NodePath("../DebugTeleporter")
|
||||||
|
|
||||||
|
[node name="DebugTeleporter" parent="Factory Tilemaps" instance=ExtResource("30_8fdby")]
|
||||||
|
position = Vector2(-801, 171)
|
||||||
|
Invisible = true
|
||||||
|
|
||||||
[node name="CameraController" type="Camera2D" parent="."]
|
[node name="CameraController" type="Camera2D" parent="."]
|
||||||
script = ExtResource("6_t8ide")
|
script = ExtResource("6_t8ide")
|
||||||
pixel_snap = false
|
pixel_snap = false
|
||||||
|
|
@ -752,10 +762,4 @@ position = Vector2(-1010, 203)
|
||||||
position = Vector2(-581, -346)
|
position = Vector2(-581, -346)
|
||||||
StartingAiState = 1
|
StartingAiState = 1
|
||||||
|
|
||||||
[node name="Shroud" type="Sprite2D" parent="."]
|
[node name="Shroud" parent="." instance=ExtResource("74_oaf68")]
|
||||||
visible = false
|
|
||||||
z_index = 1
|
|
||||||
position = Vector2(-920.5, 78.75)
|
|
||||||
scale = Vector2(127, 126.5)
|
|
||||||
texture = ExtResource("74_ra850")
|
|
||||||
script = ExtResource("75_jy7lo")
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ public partial class BlackCover : Sprite2D, IActivable
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_activated = StartActive;
|
_activated = StartActive;
|
||||||
|
UpdateSprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,29 @@
|
||||||
using Godot;
|
using System.Linq;
|
||||||
|
using Godot;
|
||||||
|
using Godot.Collections;
|
||||||
|
|
||||||
namespace Cirno.Scripts.Interactables;
|
namespace Cirno.Scripts.Interactables;
|
||||||
|
|
||||||
public partial class Switch : Interactable
|
public partial class Switch : Interactable
|
||||||
{
|
{
|
||||||
[Export] public Node2D Target { get; set; }
|
[Export] public Node2D Target { get; set; }
|
||||||
|
[Export] public Array<Node2D> Targets { get; private set; } = new Array<Node2D>();
|
||||||
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
|
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
|
||||||
|
|
||||||
public override bool Activate()
|
public override bool Activate()
|
||||||
{
|
{
|
||||||
if (MeetsRequirements() && Target is IActivable activable)
|
if (!MeetsRequirements()) return false;
|
||||||
{
|
// Compatibility for old single system
|
||||||
activable?.Activate(ActivationType);
|
bool success = ActivateTarget(Target);
|
||||||
return true;
|
|
||||||
}
|
return Targets.Aggregate(success, (current, target) => ActivateTarget(target) | success);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ActivateTarget(Node2D target)
|
||||||
|
{
|
||||||
|
if (target is not IActivable activable) return false;
|
||||||
|
activable?.Activate(ActivationType);
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue