Skip to content

Commit cb1446e

Browse files
committed
Refactored note queue
Added note queue functionality into note placement bar, for better cohesivity Simplified loading and setting notequeue Replaced overall note array and noteIdx from conductor for note arrows holding a reference to their notes. Saving save system for later, for possible reuse
1 parent adf1705 commit cb1446e

19 files changed

Lines changed: 151 additions & 230 deletions

Classes/Notes/Note.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ public partial class Note : Resource
1313
private int _baseVal;
1414
private Action<BattleDirector, Note, Timing> NoteEffect; //TODO: Where/How to deal with timing.
1515

16+
public Texture2D Texture;
17+
1618
//public string Tooltip;
1719

1820
public Note(
1921
string name,
2022
PuppetTemplate owner = null,
23+
Texture2D texture = null,
2124
int baseVal = 1,
2225
Action<BattleDirector, Note, Timing> noteEffect = null
2326
)
2427
{
2528
Name = name;
2629
Owner = owner;
30+
Texture = texture;
2731
NoteEffect =
2832
noteEffect
2933
?? (
@@ -42,6 +46,8 @@ public void OnHit(BattleDirector BD, Timing timing)
4246

4347
public Note Clone()
4448
{
49+
//Eventually could look into something more robust, but for now shallow copy is preferable.
50+
//We only would want val and name to be copied by value
4551
return (Note)MemberwiseClone();
4652
}
4753
}

scenes/CustomNotes/assets/double_note.png.import renamed to Classes/Notes/assets/double_note.png.import

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://caw70lr5e1yiq"
6-
path="res://.godot/imported/double_note.png-b077a9744f626fbc60d331cfc2e231a0.ctex"
6+
path="res://.godot/imported/double_note.png-1b788aee0b7f76d502303d178d821d3b.ctex"
77
metadata={
88
"vram_texture": false
99
}
1010

1111
[deps]
1212

13-
source_file="res://scenes/CustomNotes/assets/double_note.png"
14-
dest_files=["res://.godot/imported/double_note.png-b077a9744f626fbc60d331cfc2e231a0.ctex"]
13+
source_file="res://Classes/Notes/assets/double_note.png"
14+
dest_files=["res://.godot/imported/double_note.png-1b788aee0b7f76d502303d178d821d3b.ctex"]
1515

1616
[params]
1717

scenes/CustomNotes/assets/single_note.png.import renamed to Classes/Notes/assets/single_note.png.import

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://c3chrsxrulapd"
6-
path="res://.godot/imported/single_note.png-7542bb1712899b622105d29cce049bce.ctex"
6+
path="res://.godot/imported/single_note.png-edadc3d6779f4cc26ac823d186717719.ctex"
77
metadata={
88
"vram_texture": false
99
}
1010

1111
[deps]
1212

13-
source_file="res://scenes/CustomNotes/assets/single_note.png"
14-
dest_files=["res://.godot/imported/single_note.png-7542bb1712899b622105d29cce049bce.ctex"]
13+
source_file="res://Classes/Notes/assets/single_note.png"
14+
dest_files=["res://.godot/imported/single_note.png-edadc3d6779f4cc26ac823d186717719.ctex"]
1515

1616
[params]
1717

Globals/Scribe.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public partial class Scribe : Node
1313
new Note(
1414
"EnemyBase",
1515
null,
16+
null,
1617
1,
1718
(director, note, timing) =>
1819
{
@@ -22,6 +23,7 @@ public partial class Scribe : Node
2223
new Note(
2324
"PlayerBase",
2425
null,
26+
GD.Load<Texture2D>("res://Classes/Notes/assets/single_note.png"),
2527
1,
2628
(director, note, timing) =>
2729
{
@@ -31,6 +33,7 @@ public partial class Scribe : Node
3133
new Note(
3234
"PlayerDouble",
3335
null,
36+
GD.Load<Texture2D>("res://Classes/Notes/assets/double_note.png"),
3437
1,
3538
(director, note, timing) =>
3639
{

scenes/BattleDirector/NotePlacementBar.tscn

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
[gd_scene load_steps=6 format=3 uid="uid://duhiilcv4tat3"]
1+
[gd_scene load_steps=9 format=3 uid="uid://duhiilcv4tat3"]
22

33
[ext_resource type="Script" path="res://scenes/BattleDirector/scripts/NotePlacementBar.cs" id="1_456es"]
4+
[ext_resource type="Texture2D" uid="uid://cnyr5usjdv0ni" path="res://scenes/BattleDirector/assets/temp_note_queue.png" id="2_3tw16"]
5+
[ext_resource type="Texture2D" uid="uid://c3chrsxrulapd" path="res://Classes/Notes/assets/single_note.png" id="3_6ylx6"]
6+
[ext_resource type="Texture2D" uid="uid://caw70lr5e1yiq" path="res://Classes/Notes/assets/double_note.png" id="4_6w8ha"]
47

58
[sub_resource type="Gradient" id="Gradient_0u6yv"]
69
colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1)
@@ -20,7 +23,7 @@ width = 24
2023
height = 98
2124
fill_to = Vector2(0, 1)
2225

23-
[node name="NotePlacementBar" type="Control" node_paths=PackedStringArray("notePlacementBar", "currentComboMultText")]
26+
[node name="NotePlacementBar" type="Control" node_paths=PackedStringArray("notePlacementBar", "currentComboMultText", "_currentNote", "_nextNote")]
2427
layout_mode = 3
2528
anchors_preset = 15
2629
anchor_right = 1.0
@@ -30,6 +33,8 @@ grow_vertical = 2
3033
script = ExtResource("1_456es")
3134
notePlacementBar = NodePath("ProgressBar")
3235
currentComboMultText = NodePath("TextEdit")
36+
_currentNote = NodePath("NoteQueueSprite/CurrentNote")
37+
_nextNote = NodePath("NoteQueueSprite/NextNote")
3338

3439
[node name="ProgressBar" type="TextureProgressBar" parent="."]
3540
layout_mode = 0
@@ -54,3 +59,15 @@ deselect_on_focus_loss_enabled = false
5459
drag_and_drop_selection_enabled = false
5560
virtual_keyboard_enabled = false
5661
middle_mouse_paste_enabled = false
62+
63+
[node name="NoteQueueSprite" type="Sprite2D" parent="."]
64+
position = Vector2(84, -24)
65+
texture = ExtResource("2_3tw16")
66+
67+
[node name="CurrentNote" type="Sprite2D" parent="NoteQueueSprite"]
68+
position = Vector2(-14, -1)
69+
texture = ExtResource("3_6ylx6")
70+
71+
[node name="NextNote" type="Sprite2D" parent="NoteQueueSprite"]
72+
position = Vector2(16, -2)
73+
texture = ExtResource("4_6w8ha")
File renamed without changes.

scenes/CustomNotes/assets/temp_note_queue.png.import renamed to scenes/BattleDirector/assets/temp_note_queue.png.import

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
importer="texture"
44
type="CompressedTexture2D"
55
uid="uid://cnyr5usjdv0ni"
6-
path="res://.godot/imported/temp_note_queue.png-e563d517d16e6739ec71ecb1d9b4ade7.ctex"
6+
path="res://.godot/imported/temp_note_queue.png-b6e43682068ed18b8bf4cd7cd8229404.ctex"
77
metadata={
88
"vram_texture": false
99
}
1010

1111
[deps]
1212

13-
source_file="res://scenes/CustomNotes/assets/temp_note_queue.png"
14-
dest_files=["res://.godot/imported/temp_note_queue.png-e563d517d16e6739ec71ecb1d9b4ade7.ctex"]
13+
source_file="res://scenes/BattleDirector/assets/temp_note_queue.png"
14+
dest_files=["res://.godot/imported/temp_note_queue.png-b6e43682068ed18b8bf4cd7cd8229404.ctex"]
1515

1616
[params]
1717

scenes/BattleDirector/scripts/BattleDirector.cs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,17 @@ public partial class BattleDirector : Node2D
3232

3333
private SongData _curSong;
3434

35-
[Export]
36-
private NoteQueue NQ;
37-
3835
#endregion
3936

4037
#region Note Handling
4138
private void PlayerAddNote(ArrowType type, int beat)
4239
{
43-
//TODO: note that should be added from the queue
44-
Note note = NQ.GetCurrentNote();
45-
if (note == null)
46-
{
47-
GD.Print("No notes in queue");
48-
return;
49-
}
50-
51-
GD.Print($"Player trying to place {note.Name}:{type} typed note at beat: " + beat);
5240
if (!NotePlacementBar.CanPlaceNote())
5341
return;
54-
if (CD.AddNoteToLane(type, beat % CM.BeatsPerLoop, note, false))
42+
if (CD.AddNoteToLane(type, beat % CM.BeatsPerLoop, NotePlacementBar.PlacedNote(), false))
5543
{
56-
NotePlacementBar.PlacedNote();
5744
NotePlaced?.Invoke(this);
5845
GD.Print("Note Placed.");
59-
NQ.DequeueNote();
6046
}
6147
}
6248

@@ -86,15 +72,9 @@ public override void _Ready()
8672
AddChild(Player);
8773
Player.Defeated += CheckBattleStatus;
8874
EventizeRelics();
89-
//TODO: Refine
90-
foreach (var note in Player.Stats.CurNotes)
91-
{
92-
note.Owner = Player;
93-
CD.Notes = CD.Notes.Append(note).ToArray();
94-
}
95-
Note enemNote = Scribe.NoteDictionary[0].Clone();
96-
CD.Notes = CD.Notes.Append(enemNote).ToArray();
75+
NotePlacementBar.Setup(StageProducer.PlayerStats);
9776

77+
//TODO: Refine
9878
Enemy = new PuppetTemplate();
9979
Enemy.SetPosition(new Vector2(400, 0));
10080
AddChild(Enemy);

0 commit comments

Comments
 (0)