mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 18:15:53 +00:00
Refactored switches and chests and mapping
This commit is contained in:
parent
295d32e66d
commit
cc5376e94e
14 changed files with 158 additions and 91 deletions
|
|
@ -1,28 +1,43 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class Interactable : Area2D
|
||||
{
|
||||
[Export] public Activable Target { get; set; }
|
||||
[Export] public bool RequiresKeycard { get; set; }
|
||||
private InventoryManager _inventoryManager;
|
||||
[Export] public Array<LootItem> Requirements = new Array<LootItem>();
|
||||
|
||||
protected InventoryManager _inventoryManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
protected bool MeetsRequirements()
|
||||
{
|
||||
if (RequiresKeycard) {
|
||||
if (_inventoryManager.RedKeycard) {
|
||||
Target?.Activate();
|
||||
}
|
||||
}
|
||||
else
|
||||
if (Requirements.Any())
|
||||
{
|
||||
Target?.Activate();
|
||||
if (_inventoryManager.HasItems(Requirements.Select(x => x.Item).ToList()))
|
||||
{
|
||||
GD.Print($"Requirements for activation of {this.Name} successfully met: {string.Join(",", Requirements.Select(x => x.Item))} ");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print($"Requirements for activation of {this.Name} not met: {string.Join(",", Requirements.Select(x => x.Item))} ");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Activate()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://djf0y08ix66fn"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://djf0y08ix66fn"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Interactable.cs" id="1_4p5d3"]
|
||||
[ext_resource type="Script" path="res://Scripts/Chest.cs" id="1_cwpn7"]
|
||||
[ext_resource type="Texture2D" uid="uid://qeh4ai8h6sw5" path="res://Sprites/Chest.png" id="2_w7a1a"]
|
||||
[ext_resource type="Script" path="res://Scripts/Pickupper.cs" id="3_qro6k"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/LootItem.cs" id="4_rcd61"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ihal6"]
|
||||
radius = 16.0
|
||||
|
|
@ -76,16 +74,10 @@ animations = [{
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_isrvb"]
|
||||
size = Vector2(12, 10)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0qq1f"]
|
||||
script = ExtResource("4_rcd61")
|
||||
Item = 3
|
||||
Amount = 10
|
||||
|
||||
[node name="Chest" type="Area2D" node_paths=PackedStringArray("Target") groups=["Interactable"]]
|
||||
[node name="Chest" type="Area2D" groups=["Interactable"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_4p5d3")
|
||||
Target = NodePath("Pickupper")
|
||||
script = ExtResource("1_cwpn7")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_ihal6")
|
||||
|
|
@ -102,7 +94,3 @@ gravity_scale = 0.0
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||
position = Vector2(0, -3)
|
||||
shape = SubResource("RectangleShape2D_isrvb")
|
||||
|
||||
[node name="Pickupper" type="Node2D" parent="."]
|
||||
script = ExtResource("3_qro6k")
|
||||
LootTable = [SubResource("Resource_0qq1f")]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://crph24e6e0v0q"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Interactable.cs" id="1_g3j01"]
|
||||
[ext_resource type="Script" path="res://Scripts/Interactables/Switch.cs" id="1_alima"]
|
||||
[ext_resource type="Texture2D" uid="uid://d24g1qb40t72l" path="res://Sprites/Button_Small.png" id="2_7m30w"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_vvpve"]
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
[node name="ControlPad" type="Area2D" groups=["Interactable"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_g3j01")
|
||||
script = ExtResource("1_alima")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_vvpve")
|
||||
|
|
|
|||
11
Scenes/Interactable/control_pad_red_keycard.tscn
Normal file
11
Scenes/Interactable/control_pad_red_keycard.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cdr4m7pydqk6u"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://crph24e6e0v0q" path="res://Scenes/Interactable/Control_Pad.tscn" id="1_dv2sa"]
|
||||
[ext_resource type="Resource" uid="uid://dibquna7fww7t" path="res://Resources/Items/Red_Keycard.tres" id="2_mv5hn"]
|
||||
[ext_resource type="Texture2D" uid="uid://ch6nbhxgxxtf" path="res://Sprites/Red_Card_Reader.png" id="3_4xaqn"]
|
||||
|
||||
[node name="ControlPad" instance=ExtResource("1_dv2sa")]
|
||||
Requirements = [ExtResource("2_mv5hn")]
|
||||
|
||||
[node name="Sprite2D" parent="." index="1"]
|
||||
texture = ExtResource("3_4xaqn")
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cymtsmui4yo17"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cymtsmui4yo17"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Interactable.cs" id="1_q256v"]
|
||||
[ext_resource type="Resource" uid="uid://dibquna7fww7t" path="res://Resources/Items/Red_Keycard.tres" id="2_fqvgh"]
|
||||
[ext_resource type="Texture2D" uid="uid://ch6nbhxgxxtf" path="res://Sprites/Red_Card_Reader.png" id="2_xidhq"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_hhoab"]
|
||||
|
|
@ -10,7 +11,7 @@ radius = 12.0
|
|||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_q256v")
|
||||
RequiresKeycard = true
|
||||
Requirements = [ExtResource("2_fqvgh")]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_hhoab")
|
||||
|
|
|
|||
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_x0adl"]
|
||||
|
||||
[node name="ControlPad" type="Area2D" node_paths=PackedStringArray("Target") groups=["Interactable"]]
|
||||
[node name="ControlPad" type="Area2D" groups=["Interactable"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_8ev2v")
|
||||
Target = NodePath("Pickupper")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_x0adl")
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue