decisions decisions decisions
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7eeb6a6bf50d444f81dce3b50d9c468b580800_003F55_003Faaefec1f_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7eeb6a6bf50d444f81dce3b50d9c468b580800_003F55_003Faaefec1f_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASceneTreeAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe3fd2c31500d4d359fd6e9d5ca458884e0400_003F2f_003Faabb8bdb_003FSceneTreeAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASingletonAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe3fd2c31500d4d359fd6e9d5ca458884e0400_003F77_003F87840b05_003FSingletonAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASingletonAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe3fd2c31500d4d359fd6e9d5ca458884e0400_003F77_003F87840b05_003FSingletonAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASlimepire_002Ecore_002Emain_005Fgame_002EMainGame_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FLocal_003FTemp_003FSourceGeneratedDocuments_003FC94839DE7EFB2DDB55DF1241_003FGodotSharp_002ESourceGenerators_003FGodotSharp_002ESourceGenerators_002ESceneTreeExtensions_002ESceneTreeSourceGenerator_003FSlimepire_002Ecore_002Emain_005Fgame_002EMainGame_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASlimepire_002Ecore_002Emain_005Fgame_002EMainGame_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FLocal_003FTemp_003FSourceGeneratedDocuments_003FC94839DE7EFB2DDB55DF1241_003FGodotSharp_002ESourceGenerators_003FGodotSharp_002ESourceGenerators_002ESceneTreeExtensions_002ESceneTreeSourceGenerator_003FSlimepire_002Ecore_002Emain_005Fgame_002EMainGame_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
"uuid": "a2238a3b-e854-43e3-9655-fc856d21892b",
|
"uuid": "a2238a3b-e854-43e3-9655-fc856d21892b",
|
||||||
"title": "Todo",
|
"title": "Todo",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
"e2e29c87-042f-49e3-9c98-7ca6b258bcb7",
|
|
||||||
"36c8edc5-2708-440d-9bce-eaac534c3d84",
|
"36c8edc5-2708-440d-9bce-eaac534c3d84",
|
||||||
"49ef942e-e48b-4e79-9b61-756e061a0e1d",
|
"49ef942e-e48b-4e79-9b61-756e061a0e1d",
|
||||||
"3159b7fd-92d2-44e1-ab42-99e871e6fc77",
|
"3159b7fd-92d2-44e1-ab42-99e871e6fc77",
|
||||||
@@ -21,7 +20,9 @@
|
|||||||
{
|
{
|
||||||
"uuid": "e8652da7-7445-495d-8b60-2d303de6224a",
|
"uuid": "e8652da7-7445-495d-8b60-2d303de6224a",
|
||||||
"title": "Doing",
|
"title": "Doing",
|
||||||
"tasks": []
|
"tasks": [
|
||||||
|
"e2e29c87-042f-49e3-9c98-7ca6b258bcb7"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "7362331b-07bd-4057-830f-780196f510be",
|
"uuid": "7362331b-07bd-4057-830f-780196f510be",
|
||||||
@@ -82,7 +83,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "e2e29c87-042f-49e3-9c98-7ca6b258bcb7",
|
"uuid": "e2e29c87-042f-49e3-9c98-7ca6b258bcb7",
|
||||||
"title": "Nodules in einzelnen Scenes anstatt Resources und so",
|
"title": "Refactor Nodules",
|
||||||
"description": "",
|
"description": "",
|
||||||
"category": "4bec2406-dc3d-416b-b6c4-d8fd7425b2b5",
|
"category": "4bec2406-dc3d-416b-b6c4-d8fd7425b2b5",
|
||||||
"steps": []
|
"steps": []
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Core;
|
|
||||||
using Slimepire.Data;
|
|
||||||
using Slimepire.Gameplay.Nodules;
|
using Slimepire.Gameplay.Nodules;
|
||||||
|
using Slimepire.Gameplay.Nodules.Components;
|
||||||
|
|
||||||
namespace Slimepire.Gameplay;
|
namespace Slimepire.Gameplay;
|
||||||
|
|
||||||
@@ -11,33 +10,30 @@ public partial class BuildGhost : Node2D
|
|||||||
private Tube? _tube;
|
private Tube? _tube;
|
||||||
private readonly Dictionary<Nodule, Tube> _connectedTubes = [];
|
private readonly Dictionary<Nodule, Tube> _connectedTubes = [];
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private TubeConnectionArea _tubeConnectionArea = null!;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
TubeConnectionArea.AreaEntered += TubeConnectionAreaOnAreaEntered;
|
_tubeConnectionArea.ConnectionAdded += ConnectionAdded;
|
||||||
TubeConnectionArea.AreaExited += TubeConnectionAreaOnAreaExited;
|
_tubeConnectionArea.ConnectionRemoved += ConnectionRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaEntered(Area2D area)
|
private void ConnectionAdded(Nodule nodule)
|
||||||
{
|
{
|
||||||
if (area.GetParent() is Nodule nodule)
|
CreateGhostTube(nodule, nodule.GlobalPosition);
|
||||||
{
|
ConnectTubePlayer.Play();
|
||||||
CreateGhostTube(nodule, area.GlobalPosition);
|
|
||||||
ConnectTubePlayer.Play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaExited(Area2D area)
|
private void ConnectionRemoved(Nodule nodule)
|
||||||
{
|
{
|
||||||
if (area.GetParent() is Nodule nodule)
|
var tube = _connectedTubes.GetValueOrDefault(nodule);
|
||||||
{
|
if (tube == null)
|
||||||
var tube = _connectedTubes.GetValueOrDefault(nodule);
|
return;
|
||||||
if (tube == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_connectedTubes.Remove(nodule);
|
_connectedTubes.Remove(nodule);
|
||||||
tube.QueueFree();
|
tube.QueueFree();
|
||||||
DisconnectTubePlayer.Play();
|
DisconnectTubePlayer.Play();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateGhostTube(Nodule connectedNodule, Vector2 pos)
|
private void CreateGhostTube(Nodule connectedNodule, Vector2 pos)
|
||||||
@@ -83,9 +79,9 @@ public partial class BuildGhost : Node2D
|
|||||||
var nodule = Instantiator.Instantiate<Nodule>();
|
var nodule = Instantiator.Instantiate<Nodule>();
|
||||||
|
|
||||||
nodule.Position = Position;
|
nodule.Position = Position;
|
||||||
nodule.NoduleResource = GD.Load<NoduleResource>(
|
// nodule.NoduleResource = GD.Load<NoduleResource>(
|
||||||
GameResources.SimpleNoduleTres.ResourcePath
|
// GameResources.SimpleNoduleTres.ResourcePath
|
||||||
);
|
// );
|
||||||
|
|
||||||
GetParent()?.AddChild(nodule);
|
GetParent()?.AddChild(nodule);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ck5yw760bu8sb" path="res://src/Gameplay/BuildGhost.cs" id="1_ahcoi"]
|
[ext_resource type="Script" uid="uid://ck5yw760bu8sb" path="res://src/Gameplay/BuildGhost.cs" id="1_ahcoi"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_uo42j"]
|
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_uo42j"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bjesfu1mfx8l5" path="res://src/Gameplay/Nodules/Components/TubeConnectionArea.tscn" id="2_vecmk"]
|
||||||
[ext_resource type="AudioStream" uid="uid://mj8wvuwfc6o7" path="res://assets/sfx/tube_disconnect.wav" id="3_nxaxp"]
|
[ext_resource type="AudioStream" uid="uid://mj8wvuwfc6o7" path="res://assets/sfx/tube_disconnect.wav" id="3_nxaxp"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bxxi7grsubvgm" path="res://assets/sfx/tube_connect.wav" id="3_quiac"]
|
[ext_resource type="AudioStream" uid="uid://bxxi7grsubvgm" path="res://assets/sfx/tube_connect.wav" id="3_quiac"]
|
||||||
|
|
||||||
@@ -29,31 +30,22 @@ animations = [{
|
|||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_quiac")
|
"texture": SubResource("AtlasTexture_quiac")
|
||||||
}],
|
}],
|
||||||
"loop": true,
|
"loop": 1,
|
||||||
"name": &"default",
|
"name": &"default",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_uo42j"]
|
[node name="BuildGhost" type="Node2D" unique_id=150653292 node_paths=PackedStringArray("_tubeConnectionArea")]
|
||||||
radius = 96.38
|
|
||||||
|
|
||||||
[node name="BuildGhost" type="Node2D" unique_id=150653292]
|
|
||||||
script = ExtResource("1_ahcoi")
|
script = ExtResource("1_ahcoi")
|
||||||
|
_tubeConnectionArea = NodePath("TubeConnectionArea")
|
||||||
|
|
||||||
|
[node name="TubeConnectionArea" parent="." unique_id=1821668398 instance=ExtResource("2_vecmk")]
|
||||||
|
|
||||||
[node name="Sprite2D" type="AnimatedSprite2D" parent="." unique_id=260566565]
|
[node name="Sprite2D" type="AnimatedSprite2D" parent="." unique_id=260566565]
|
||||||
self_modulate = Color(0.1752002, 0.36830294, 0.26058322, 0.50980395)
|
self_modulate = Color(0.1752002, 0.36830294, 0.26058322, 0.50980395)
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
sprite_frames = SubResource("SpriteFrames_vecmk")
|
sprite_frames = SubResource("SpriteFrames_vecmk")
|
||||||
|
|
||||||
[node name="TubeConnectionArea" type="Area2D" parent="." unique_id=2116427547]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
collision_layer = 2
|
|
||||||
collision_mask = 2
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TubeConnectionArea" unique_id=1558952717]
|
|
||||||
shape = SubResource("CircleShape2D_uo42j")
|
|
||||||
debug_color = Color(0.38922516, 0.6054754, 0.25354394, 0.41960785)
|
|
||||||
|
|
||||||
[node name="ConnectTubePlayer" type="AudioStreamPlayer" parent="." unique_id=111889028]
|
[node name="ConnectTubePlayer" type="AudioStreamPlayer" parent="." unique_id=111889028]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("3_quiac")
|
stream = ExtResource("3_quiac")
|
||||||
|
|||||||
57
src/Gameplay/Nodules/Components/GrowArea.cs
Normal file
57
src/Gameplay/Nodules/Components/GrowArea.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using Godot;
|
||||||
|
using Slimepire.Core;
|
||||||
|
|
||||||
|
namespace Slimepire.Gameplay.Nodules.Components;
|
||||||
|
|
||||||
|
[SceneTree]
|
||||||
|
public partial class GrowArea : Area2D
|
||||||
|
{
|
||||||
|
private bool _mouseInsideClickArea;
|
||||||
|
private bool _clickedInside;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
MouseEntered += ClickAreaOnMouseEntered;
|
||||||
|
MouseExited += ClickAreaOnMouseExited;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClickAreaOnMouseEntered()
|
||||||
|
{
|
||||||
|
_mouseInsideClickArea = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClickAreaOnMouseExited()
|
||||||
|
{
|
||||||
|
_mouseInsideClickArea = false;
|
||||||
|
|
||||||
|
// ghost == null check probably unnecessary
|
||||||
|
if (_clickedInside && !NoduleManager.Instance.Building)
|
||||||
|
{
|
||||||
|
NoduleManager.Instance.Building = true;
|
||||||
|
_clickedInside = false;
|
||||||
|
|
||||||
|
var ghost = Instantiator.Instantiate<BuildGhost>();
|
||||||
|
ghost.Position = Position;
|
||||||
|
|
||||||
|
// TODO: Make it better... EntityRoot oder vllt. NoduleRoot
|
||||||
|
// Oder einfach den Baum auch als Baum in der Scene darstellen?
|
||||||
|
GetTree().Root.AddChild(ghost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
|
{
|
||||||
|
using (@event)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
@event is InputEventMouseButton { ButtonIndex: MouseButton.Left }
|
||||||
|
&& @event.IsPressed()
|
||||||
|
&& _mouseInsideClickArea
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_clickedInside = true;
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/Gameplay/Nodules/Components/GrowArea.cs.uid
Normal file
1
src/Gameplay/Nodules/Components/GrowArea.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cfxb8wmnt7ej7
|
||||||
13
src/Gameplay/Nodules/Components/GrowArea.tscn
Normal file
13
src/Gameplay/Nodules/Components/GrowArea.tscn
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_scene format=3 uid="uid://3x5pqm4t5cbl"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cfxb8wmnt7ej7" path="res://src/Gameplay/Nodules/Components/GrowArea.cs" id="1_a3tcn"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_7qt20"]
|
||||||
|
radius = 15.0
|
||||||
|
|
||||||
|
[node name="GrowArea" type="Area2D" unique_id=979341496]
|
||||||
|
monitorable = false
|
||||||
|
script = ExtResource("1_a3tcn")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1616623898]
|
||||||
|
shape = SubResource("CircleShape2D_7qt20")
|
||||||
31
src/Gameplay/Nodules/Components/TubeConnectionArea.cs
Normal file
31
src/Gameplay/Nodules/Components/TubeConnectionArea.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Slimepire.Gameplay.Nodules.Components;
|
||||||
|
|
||||||
|
public partial class TubeConnectionArea : Area2D
|
||||||
|
{
|
||||||
|
public Action<Nodule> ConnectionAdded { get; set; }
|
||||||
|
public Action<Nodule> ConnectionRemoved { get; set; }
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
AreaEntered += TubeConnectionAreaOnAreaEntered;
|
||||||
|
AreaExited += TubeConnectionAreaOnAreaExited;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TubeConnectionAreaOnAreaEntered(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
|
{
|
||||||
|
ConnectionAdded?.Invoke(nodule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TubeConnectionAreaOnAreaExited(Area2D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is Nodule nodule)
|
||||||
|
{
|
||||||
|
ConnectionRemoved?.Invoke(nodule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bcw8vylpb533h
|
||||||
15
src/Gameplay/Nodules/Components/TubeConnectionArea.tscn
Normal file
15
src/Gameplay/Nodules/Components/TubeConnectionArea.tscn
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bjesfu1mfx8l5"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bcw8vylpb533h" path="res://src/Gameplay/Nodules/Components/TubeConnectionArea.cs" id="1_uhdst"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_x44k2"]
|
||||||
|
radius = 96.38
|
||||||
|
|
||||||
|
[node name="TubeConnectionArea" type="Area2D" unique_id=1821668398]
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 2
|
||||||
|
script = ExtResource("1_uhdst")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=301201606]
|
||||||
|
shape = SubResource("CircleShape2D_x44k2")
|
||||||
|
debug_color = Color(0.38922516, 0.6054754, 0.25354394, 0.41960785)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Slimepire.Data;
|
using Slimepire.Gameplay.Nodules.Components;
|
||||||
|
|
||||||
namespace Slimepire.Gameplay.Nodules;
|
namespace Slimepire.Gameplay.Nodules;
|
||||||
|
|
||||||
@@ -8,105 +8,31 @@ public partial class Nodule : Node2D
|
|||||||
{
|
{
|
||||||
public long Id { get; set; } = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0);
|
public long Id { get; set; } = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0);
|
||||||
|
|
||||||
private bool _mouseInsideClickArea;
|
public List<Nodule> Connections { get; } = [];
|
||||||
private bool _clickedInside;
|
|
||||||
|
|
||||||
public readonly List<Nodule> Connections = [];
|
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public required NoduleResource NoduleResource;
|
private TubeConnectionArea _tubeConnectionArea;
|
||||||
|
|
||||||
private float energy = 0;
|
|
||||||
|
|
||||||
// todo remove?
|
|
||||||
private bool _isExpanding;
|
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Gfx.SpriteFrames = NoduleResource.SpriteFrames;
|
Gfx.SelfModulate = Colors.DarkOliveGreen;
|
||||||
Gfx.SelfModulate = NoduleResource.Color;
|
|
||||||
Gfx.Play();
|
Gfx.Play();
|
||||||
|
|
||||||
ClickArea.MouseEntered += ClickAreaOnMouseEntered;
|
_tubeConnectionArea.ConnectionAdded += ConnectionAdded;
|
||||||
ClickArea.MouseExited += ClickAreaOnMouseExited;
|
_tubeConnectionArea.ConnectionRemoved += ConnectionRemoved;
|
||||||
|
|
||||||
TubeConnectionArea.AreaEntered += TubeConnectionAreaOnAreaEntered;
|
|
||||||
TubeConnectionArea.AreaExited += TubeConnectionAreaOnAreaExited;
|
|
||||||
|
|
||||||
NoduleManager.Instance.RegisterNodule(this);
|
NoduleManager.Instance.RegisterNodule(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
private void ConnectionAdded(Nodule nodule)
|
||||||
{
|
{
|
||||||
EnergyLabel.Text = energy.ToString("F2");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaEntered(Area2D area)
|
|
||||||
{
|
|
||||||
if (area.GetParent() is Nodule nodule)
|
|
||||||
{
|
|
||||||
Connections.Add(nodule);
|
|
||||||
NoduleManager.Instance.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TubeConnectionAreaOnAreaExited(Area2D area)
|
|
||||||
{
|
|
||||||
if (area.GetParent() is Nodule nodule)
|
|
||||||
{
|
|
||||||
Connections.Remove(nodule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _UnhandledInput(InputEvent @event)
|
|
||||||
{
|
|
||||||
using (@event)
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
@event is InputEventMouseButton { ButtonIndex: MouseButton.Left }
|
|
||||||
&& @event.IsPressed()
|
|
||||||
&& _mouseInsideClickArea
|
|
||||||
)
|
|
||||||
{
|
|
||||||
_clickedInside = true;
|
|
||||||
GetViewport().SetInputAsHandled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ClickAreaOnMouseEntered()
|
|
||||||
{
|
|
||||||
_mouseInsideClickArea = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ClickAreaOnMouseExited()
|
|
||||||
{
|
|
||||||
_mouseInsideClickArea = false;
|
|
||||||
|
|
||||||
// ghost == null check probably unnecessary
|
|
||||||
if (_clickedInside && !NoduleManager.Instance.Building)
|
|
||||||
{
|
|
||||||
NoduleManager.Instance.Building = true;
|
|
||||||
_clickedInside = false;
|
|
||||||
_isExpanding = true;
|
|
||||||
|
|
||||||
var ghost = Instantiator.Instantiate<BuildGhost>();
|
|
||||||
ghost.Position = Position;
|
|
||||||
|
|
||||||
GetParent()?.AddChild(ghost);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnBuildComplete(Vector2 pos)
|
|
||||||
{
|
|
||||||
NoduleManager.Instance.Building = false;
|
|
||||||
_isExpanding = false;
|
|
||||||
|
|
||||||
var nodule = Instantiator.Instantiate<Nodule>();
|
|
||||||
|
|
||||||
nodule.Position = pos;
|
|
||||||
Connections.Add(nodule);
|
Connections.Add(nodule);
|
||||||
nodule.Connections.Add(this);
|
NoduleManager.Instance.Update();
|
||||||
GetParent()?.AddChild(nodule);
|
}
|
||||||
|
|
||||||
|
private void ConnectionRemoved(Nodule nodule)
|
||||||
|
{
|
||||||
|
Connections.Remove(nodule);
|
||||||
|
NoduleManager.Instance.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cmpl0if164dba" path="res://src/Gameplay/Nodules/Nodule.cs" id="1_yembh"]
|
[ext_resource type="Script" uid="uid://cmpl0if164dba" path="res://src/Gameplay/Nodules/Nodule.cs" id="1_yembh"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_7qt20"]
|
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_7qt20"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bjesfu1mfx8l5" path="res://src/Gameplay/Nodules/Components/TubeConnectionArea.tscn" id="2_inlcu"]
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_7qt20"]
|
[ext_resource type="PackedScene" uid="uid://3x5pqm4t5cbl" path="res://src/Gameplay/Nodules/Components/GrowArea.tscn" id="2_x44k2"]
|
||||||
radius = 15.0
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7qt20"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_7qt20"]
|
||||||
atlas = ExtResource("2_7qt20")
|
atlas = ExtResource("2_7qt20")
|
||||||
@@ -35,9 +34,6 @@ animations = [{
|
|||||||
"speed": 2.0
|
"speed": 2.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_x44k2"]
|
|
||||||
radius = 96.38
|
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_x44k2"]
|
[sub_resource type="LabelSettings" id="LabelSettings_x44k2"]
|
||||||
font_size = 12
|
font_size = 12
|
||||||
outline_size = 3
|
outline_size = 3
|
||||||
@@ -45,15 +41,14 @@ outline_color = Color(0, 0, 0, 1)
|
|||||||
shadow_size = 3
|
shadow_size = 3
|
||||||
shadow_color = Color(0, 0, 0, 1)
|
shadow_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
[node name="Nodule" type="Node2D" unique_id=1637542829]
|
[node name="Nodule" type="Node2D" unique_id=1637542829 node_paths=PackedStringArray("_tubeConnectionArea")]
|
||||||
z_index = 1
|
z_index = 1
|
||||||
script = ExtResource("1_yembh")
|
script = ExtResource("1_yembh")
|
||||||
|
_tubeConnectionArea = NodePath("TubeConnectionArea")
|
||||||
|
|
||||||
[node name="ClickArea" type="Area2D" parent="." unique_id=120357381]
|
[node name="TubeConnectionArea" parent="." unique_id=1821668398 instance=ExtResource("2_inlcu")]
|
||||||
unique_name_in_owner = true
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="ClickArea" unique_id=2005066434]
|
[node name="GrowArea" parent="." unique_id=979341496 instance=ExtResource("2_x44k2")]
|
||||||
shape = SubResource("CircleShape2D_7qt20")
|
|
||||||
|
|
||||||
[node name="Gfx" type="AnimatedSprite2D" parent="." unique_id=190397869]
|
[node name="Gfx" type="AnimatedSprite2D" parent="." unique_id=190397869]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
@@ -62,15 +57,6 @@ sprite_frames = SubResource("SpriteFrames_xyjsl")
|
|||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
frame_progress = 0.120879106
|
frame_progress = 0.120879106
|
||||||
|
|
||||||
[node name="TubeConnectionArea" type="Area2D" parent="." unique_id=339547035]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
collision_layer = 2
|
|
||||||
collision_mask = 2
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TubeConnectionArea" unique_id=234655540]
|
|
||||||
shape = SubResource("CircleShape2D_x44k2")
|
|
||||||
debug_color = Color(0.38922516, 0.6054754, 0.25354394, 0.41960785)
|
|
||||||
|
|
||||||
[node name="EnergyLabel" type="Label" parent="." unique_id=466024399]
|
[node name="EnergyLabel" type="Label" parent="." unique_id=466024399]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dwunaa303epy6" path="res://src/Gameplay/Tube.cs" id="1_76hpl"]
|
[ext_resource type="Script" uid="uid://dwunaa303epy6" path="res://src/Gameplay/Tube.cs" id="1_76hpl"]
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_0lkqj"]
|
[sub_resource type="Curve" id="Curve_kvwlm"]
|
||||||
_limits = [0.0, 2.0, 0.0, 1.0]
|
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.5, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.5, 1.4598354), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
|
||||||
point_count = 3
|
point_count = 3
|
||||||
|
|
||||||
[node name="Tube" type="Node2D" unique_id=226677696]
|
[node name="Tube" type="Node2D" unique_id=226677696]
|
||||||
@@ -13,13 +12,14 @@ script = ExtResource("1_76hpl")
|
|||||||
[node name="Line2D" type="Line2D" parent="." unique_id=1553055261]
|
[node name="Line2D" type="Line2D" parent="." unique_id=1553055261]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
z_as_relative = false
|
z_as_relative = false
|
||||||
|
points = PackedVector2Array(0, 0, 32.6, 17, 65.2, 34, 97.799995, 51, 163, 85)
|
||||||
width = 8.0
|
width = 8.0
|
||||||
width_curve = SubResource("Curve_0lkqj")
|
width_curve = SubResource("Curve_kvwlm")
|
||||||
default_color = Color(0.30588236, 0.4862745, 0.23921569, 0.5568628)
|
default_color = Color(0.30588236, 0.4862745, 0.23921569, 1)
|
||||||
joint_mode = 2
|
joint_mode = 2
|
||||||
begin_cap_mode = 2
|
begin_cap_mode = 2
|
||||||
end_cap_mode = 2
|
end_cap_mode = 2
|
||||||
|
|
||||||
[node name="Target" type="Marker2D" parent="." unique_id=630564540]
|
[node name="Target" type="Marker2D" parent="." unique_id=630564540]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
position = Vector2(47, 66)
|
position = Vector2(163, 85)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
[ext_resource type="Script" uid="uid://c8l12dlpexosv" path="res://src/Levels/DemoLevel.cs" id="1_l2cn0"]
|
[ext_resource type="Script" uid="uid://c8l12dlpexosv" path="res://src/Levels/DemoLevel.cs" id="1_l2cn0"]
|
||||||
[ext_resource type="Script" uid="uid://cdgi3y0sm3rt1" path="res://src/Gameplay/Camera.cs" id="2_mxa1b"]
|
[ext_resource type="Script" uid="uid://cdgi3y0sm3rt1" path="res://src/Gameplay/Camera.cs" id="2_mxa1b"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cnl6t8o4mh0j3" path="res://src/Gameplay/Nodules/Nodule.tscn" id="3_qhkhc"]
|
[ext_resource type="PackedScene" uid="uid://cnl6t8o4mh0j3" path="res://src/Gameplay/Nodules/Nodule.tscn" id="3_qhkhc"]
|
||||||
[ext_resource type="Resource" uid="uid://0d8vif4ejtp1" path="res://src/Data/EnergyStorageNodule.tres" id="4_yyao7"]
|
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_l2cn0"]
|
[sub_resource type="LabelSettings" id="LabelSettings_l2cn0"]
|
||||||
font_size = 107
|
font_size = 107
|
||||||
@@ -30,4 +29,3 @@ text = "DEMO LEVEL"
|
|||||||
label_settings = SubResource("LabelSettings_l2cn0")
|
label_settings = SubResource("LabelSettings_l2cn0")
|
||||||
|
|
||||||
[node name="Nodule" parent="." unique_id=1637542829 instance=ExtResource("3_qhkhc")]
|
[node name="Nodule" parent="." unique_id=1637542829 instance=ExtResource("3_qhkhc")]
|
||||||
NoduleResource = ExtResource("4_yyao7")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user