Skip to content

Commit a40e11e

Browse files
authored
Added Enemy notes (#195)
* Simplify note owner This never needs to be in the constructor Added SetOwner function * Separate Adding Note logic Player notes now are sorted correctly Scaffolding AddConcurrentNote * Refactored placement to take advantage of sorting Consider this change experimental, not 100% sure the SpawnNotesAtBeat loop works exactly as intended. * Enemies can add concurrent notes Temperamental conditions Notes in the first visible parts of the chart have to be added on battle start, with a 1 loop offset Otherwise, they HAVE to be added OnLoop, with beatPos set and loop 0 They cannot overwrite player notes, will throw a completely safe warning * Implemented sample GWS note * Added Applying note types Any puppet can apply note types to base notes Limitations: Notes are only applied to notes that had EnemyBase. Notes can only be applied randomly. * Index OOB fix
1 parent aaadd6c commit a40e11e

9 files changed

Lines changed: 276 additions & 47 deletions

File tree

Classes/Notes/Assets/Note_GWS.png

607 Bytes
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://bqng2uofbio1x"
6+
path="res://.godot/imported/Note_GWS.png-374fb66d7b5ccdab1c51d6ad3d49769c.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://Classes/Notes/Assets/Note_GWS.png"
14+
dest_files=["res://.godot/imported/Note_GWS.png-374fb66d7b5ccdab1c51d6ad3d49769c.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

Classes/Notes/Note.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public Note(
2222
int id,
2323
string name,
2424
Texture2D texture = null,
25-
PuppetTemplate owner = null,
2625
int baseVal = 1,
2726
Action<BattleDirector, Note, Timing> noteEffect = null,
2827
float costModifier = 1.0f,
@@ -31,7 +30,6 @@ public Note(
3130
{
3231
Id = id;
3332
Name = name;
34-
Owner = owner;
3533
NoteEffect = noteEffect;
3634
_baseVal = baseVal;
3735
Texture = texture;
@@ -44,20 +42,17 @@ public void OnHit(BattleDirector BD, Timing timing)
4442
NoteEffect(BD, this, timing);
4543
}
4644

45+
public Note SetOwner(PuppetTemplate owner)
46+
{
47+
Owner = owner;
48+
return this;
49+
}
50+
4751
public Note Clone()
4852
{
4953
//Eventually could look into something more robust, but for now shallow copy is preferable.
5054
//We only would want val and name to be copied by value
51-
Note newNote = new Note(
52-
Id,
53-
Name,
54-
Texture,
55-
Owner,
56-
_baseVal,
57-
NoteEffect,
58-
CostModifier,
59-
TargetType
60-
);
55+
Note newNote = new Note(Id, Name, Texture, _baseVal, NoteEffect, CostModifier, TargetType);
6156
return newNote;
6257
}
6358

Globals/FunkEngineNameSpace.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public ArrowData(ArrowType type, Beat beat, Note note, double length = 0)
5555
public Beat Beat;
5656
public readonly double Length; //in beats, should never be >= loop
5757
public readonly ArrowType Type;
58-
public readonly Note NoteRef = null;
58+
public Note NoteRef { get; private set; } = null;
5959

6060
public static ArrowData Placeholder { get; private set; } =
6161
new(default, default, new Note(-1, ""));
@@ -66,6 +66,18 @@ public ArrowData BeatFromLength()
6666
return this;
6767
}
6868

69+
public static ArrowData SetNote(ArrowData arrowData, Note note)
70+
{
71+
arrowData.NoteRef = note;
72+
return arrowData;
73+
}
74+
75+
public ArrowData IncDecLoop(int amount)
76+
{
77+
Beat.IncDecLoop(amount);
78+
return this;
79+
}
80+
6981
public bool Equals(ArrowData other)
7082
{
7183
return Beat.Equals(other.Beat) && Type == other.Type;

Globals/Scribe.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public partial class Scribe : Node
1717
0,
1818
"EnemyBase",
1919
null,
20-
null,
2120
1,
2221
(director, note, timing) =>
2322
{
@@ -29,7 +28,6 @@ public partial class Scribe : Node
2928
1,
3029
"PlayerBase",
3130
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerBasic.png"),
32-
null,
3331
4,
3432
(director, note, timing) =>
3533
{
@@ -42,7 +40,6 @@ public partial class Scribe : Node
4240
2,
4341
"PlayerDouble",
4442
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerDouble.png"),
45-
null,
4643
8,
4744
(director, note, timing) =>
4845
{
@@ -55,7 +52,6 @@ public partial class Scribe : Node
5552
3,
5653
"PlayerHeal",
5754
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerHeal.png"),
58-
null,
5955
1,
6056
(director, note, timing) =>
6157
{
@@ -68,7 +64,6 @@ public partial class Scribe : Node
6864
4,
6965
"PlayerVampire",
7066
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerVampire.png"),
71-
null,
7267
3,
7368
(director, note, timing) =>
7469
{
@@ -83,7 +78,6 @@ public partial class Scribe : Node
8378
5,
8479
"PlayerQuarter",
8580
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerQuarter.png"),
86-
null,
8781
3,
8882
(director, note, timing) =>
8983
{
@@ -97,7 +91,6 @@ public partial class Scribe : Node
9791
6,
9892
"PlayerBlock",
9993
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerBlock.png"),
100-
null,
10194
1,
10295
(director, note, timing) =>
10396
{
@@ -110,7 +103,6 @@ public partial class Scribe : Node
110103
7,
111104
"PlayerExplosive",
112105
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerExplosive.png"),
113-
null,
114106
4,
115107
(director, note, timing) =>
116108
{
@@ -125,7 +117,6 @@ public partial class Scribe : Node
125117
8,
126118
"PlayerEcho",
127119
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerEcho.png"),
128-
null,
129120
4,
130121
(director, note, timing) =>
131122
{
@@ -139,7 +130,6 @@ public partial class Scribe : Node
139130
9,
140131
"PlayerPoison",
141132
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_PlayerPoison.png"),
142-
null,
143133
1,
144134
(director, note, timing) =>
145135
{
@@ -148,6 +138,19 @@ public partial class Scribe : Node
148138
director.AddStatus(Targetting.First, StatusEffect.Poison.GetInstance((int)timing));
149139
}
150140
),
141+
new Note(
142+
10,
143+
"GWS",
144+
GD.Load<Texture2D>("res://Classes/Notes/Assets/Note_GWS.png"),
145+
1,
146+
(director, note, timing) =>
147+
{
148+
int dmg = 2 * (3 - (int)timing) * note.GetBaseVal() + TimeKeeper.LastBeat.Loop; //Double an enemy base plus the loop num, unless perfect
149+
if (timing == Timing.Perfect)
150+
dmg = 0;
151+
director.DealDamage(Targetting.Player, dmg, note.Owner);
152+
}
153+
),
151154
};
152155

153156
public static readonly RelicTemplate[] RelicDictionary = new[]

Scenes/BattleDirector/Scripts/BattleDirector.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public override void _Ready()
9696
InitPlayer();
9797
InitEnemies();
9898
InitScoringGuide();
99-
CD.Initialize(curSong);
99+
CD.Initialize(curSong, _enemies);
100100
CD.NoteInputEvent += OnTimedInput;
101101

102102
FocusedButton.GrabFocus();
@@ -214,12 +214,26 @@ public bool PlayerAddNote(ArrowType type, Beat beat)
214214
Note noteToPlace = NPB.NotePlaced();
215215
noteToPlace.OnHit(this, Timing.Okay);
216216

217-
CD.AddPlayerNote(noteToPlace, type, beat);
217+
CD.AddPlayerNote(noteToPlace.SetOwner(Player), type, beat);
218218
Harbinger.Instance.InvokeNotePlaced(new ArrowData(type, beat, noteToPlace));
219219
Harbinger.Instance.InvokeNoteHit(noteToPlace, Timing.Okay); //TODO: test how this feels? maybe take it out later
220220
return true;
221221
}
222222

223+
public bool EnemyAddNote(ArrowType type, Beat beat, Note noteRef, float len, EnemyPuppet enemy)
224+
{
225+
noteRef.SetOwner(enemy);
226+
Beat realBeat = TimeKeeper.GetBeatFromTime(Audio.GetPlaybackPosition());
227+
return CD.AddConcurrentNote(realBeat, noteRef, type, beat.IncDecLoop(realBeat.Loop), len);
228+
}
229+
230+
public void RandApplyNote(PuppetTemplate owner, int noteId, int amount)
231+
{
232+
if (owner == null || noteId > Scribe.NoteDictionary.Length || amount < 1)
233+
return;
234+
CD.SetRandBaseNoteToType(owner, (noteId, amount));
235+
}
236+
223237
//Only called from CD signal when a note is processed
224238
private void OnTimedInput(ArrowData data, double beatDif)
225239
{

0 commit comments

Comments
 (0)