-
Notifications
You must be signed in to change notification settings - Fork 0
Sprint 2 Complete #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0d77e31
fc51749
aba3e03
450197b
abea625
b3c0a27
3b73620
36cef29
b67fb1f
a0d67a1
e367ff5
e0b2063
c8b0227
3137144
b1a27eb
9f08b0e
5e97038
2c5311a
3de4c2d
3b79813
1241600
91eb416
a7f9dee
9567f84
8403182
ee4dc88
8e3ab6c
adf1705
cb1446e
692cf28
175a64b
55de3ec
1cdd479
1f69fef
74506ee
4590b5c
6f0e415
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| using System; | ||
| using FunkEngine; | ||
| using Godot; | ||
|
|
||
| /** | ||
| * @class Note | ||
| * @brief Data structure class for holding data and methods for a battle time note. WIP | ||
| */ | ||
| public partial class Note : Resource | ||
| { | ||
| public PuppetTemplate Owner; | ||
| public string Name; | ||
| private int _baseVal; | ||
| private Action<BattleDirector, Note, Timing> NoteEffect; //TODO: Where/How to deal with timing. | ||
|
|
||
| public string Tooltip; | ||
| public Texture2D Texture; | ||
|
|
||
| public Note( | ||
| string name, | ||
| string tooltip, | ||
| Texture2D texture = null, | ||
| PuppetTemplate owner = null, | ||
| int baseVal = 1, | ||
| Action<BattleDirector, Note, Timing> noteEffect = null | ||
| ) | ||
| { | ||
| Name = name; | ||
| Owner = owner; | ||
| NoteEffect = | ||
| noteEffect | ||
| ?? ( | ||
| (BD, source, Timing) => | ||
| { | ||
| BD.GetTarget(this).TakeDamage(source._baseVal); | ||
| } | ||
| ); | ||
| _baseVal = baseVal; | ||
| Texture = texture; | ||
| Tooltip = tooltip; | ||
| } | ||
|
|
||
| public void OnHit(BattleDirector BD, Timing timing) | ||
| { | ||
| NoteEffect(BD, this, timing); | ||
| } | ||
|
|
||
| public Note Clone() | ||
| { | ||
| //Eventually could look into something more robust, but for now shallow copy is preferable. | ||
| //We only would want val and name to be copied by value | ||
| Note newNote = new Note(Name, Tooltip, Texture, Owner, _baseVal, NoteEffect); | ||
| return newNote; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [remap] | ||
|
|
||
| importer="texture" | ||
| type="CompressedTexture2D" | ||
| uid="uid://c3chrsxrulapd" | ||
| path="res://.godot/imported/single_note.png-edadc3d6779f4cc26ac823d186717719.ctex" | ||
| metadata={ | ||
| "vram_texture": false | ||
| } | ||
|
|
||
| [deps] | ||
|
|
||
| source_file="res://Classes/Notes/assets/single_note.png" | ||
| dest_files=["res://.godot/imported/single_note.png-edadc3d6779f4cc26ac823d186717719.ctex"] | ||
|
|
||
| [params] | ||
|
|
||
| compress/mode=0 | ||
| compress/high_quality=false | ||
| compress/lossy_quality=0.7 | ||
| compress/hdr_compression=1 | ||
| compress/normal_map=0 | ||
| compress/channel_pack=0 | ||
| mipmaps/generate=false | ||
| mipmaps/limit=-1 | ||
| roughness/mode=0 | ||
| roughness/src_normal="" | ||
| process/fix_alpha_border=true | ||
| process/premult_alpha=false | ||
| process/normal_map_invert_y=false | ||
| process/hdr_as_srgb=false | ||
| process/hdr_clamp_exposure=false | ||
| process/size_limit=0 | ||
| detect_3d/compress_to=1 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||
| using System; | ||||||||||||||||||||||||
| using FunkEngine; | ||||||||||||||||||||||||
| using Godot; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public partial class RelicEffect : IBattleEvent | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| private BattleEffectTrigger Trigger { get; set; } | ||||||||||||||||||||||||
| public int BaseValue; | ||||||||||||||||||||||||
| private Action<BattleDirector, int> OnRelicEffect; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public RelicEffect( | ||||||||||||||||||||||||
| BattleEffectTrigger trigger, | ||||||||||||||||||||||||
| int val, | ||||||||||||||||||||||||
| Action<BattleDirector, int> onRelicEffect | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| BaseValue = val; | ||||||||||||||||||||||||
| Trigger = trigger; | ||||||||||||||||||||||||
| OnRelicEffect = onRelicEffect; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public void OnTrigger(BattleDirector battleDirector) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| OnRelicEffect(battleDirector, BaseValue); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null check before invoking OnRelicEffect. Consider adding a null check to prevent potential NullReferenceException. public void OnTrigger(BattleDirector battleDirector)
{
+ if (battleDirector == null)
+ throw new ArgumentNullException(nameof(battleDirector));
+
OnRelicEffect(battleDirector, BaseValue);
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public BattleEffectTrigger GetTrigger() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| return Trigger; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using System; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using FunkEngine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Godot; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public partial class RelicTemplate : Resource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RelicEffect[] Effects; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public string Name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public Texture2D Texture; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public string Tooltip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use properties instead of public fields and add documentation. Consider encapsulating fields as properties and adding XML documentation for better maintainability. +/// <summary>
+/// Represents a template for game relics, defining their properties and effects.
+/// </summary>
public partial class RelicTemplate : Resource
{
- public RelicEffect[] Effects;
- public string Name;
- public Texture2D Texture;
- public string Tooltip;
+ /// <summary>
+ /// Gets or sets the effects associated with this relic.
+ /// </summary>
+ public RelicEffect[] Effects { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of the relic.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the texture used to display the relic.
+ /// </summary>
+ public Texture2D Texture { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tooltip description of the relic.
+ /// </summary>
+ public string Tooltip { get; set; }📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RelicTemplate( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| string name = "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| string tooltip = "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Texture2D texture = null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RelicEffect[] EffectTags = null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Effects = EffectTags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name = name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Tooltip = tooltip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Texture = texture; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public RelicTemplate Clone() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RelicTemplate newRelic = new RelicTemplate(Name, Tooltip, Texture, Effects); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return newRelic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement deep copy for Effects array. The current implementation performs a shallow copy of the Effects array, which could lead to shared state between clones. public RelicTemplate Clone()
{
- RelicTemplate newRelic = new RelicTemplate(Name, Tooltip, Texture, Effects);
+ RelicTemplate newRelic = new RelicTemplate(
+ Name,
+ Tooltip,
+ Texture,
+ Effects?.Select(effect => new RelicEffect(
+ effect.GetTrigger(),
+ effect.BaseValue,
+ effect.OnRelicEffect
+ )).ToArray()
+ );
return newRelic;
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [remap] | ||
|
|
||
| importer="texture" | ||
| type="CompressedTexture2D" | ||
| uid="uid://csjx2hb4tdlw8" | ||
| path="res://.godot/imported/relic_Breakfast.png-c1b968058adbb855fcf957a2aec74dc2.ctex" | ||
| metadata={ | ||
| "vram_texture": false | ||
| } | ||
|
|
||
| [deps] | ||
|
|
||
| source_file="res://Classes/Relics/assets/relic_Breakfast.png" | ||
| dest_files=["res://.godot/imported/relic_Breakfast.png-c1b968058adbb855fcf957a2aec74dc2.ctex"] | ||
|
|
||
| [params] | ||
|
|
||
| compress/mode=0 | ||
| compress/high_quality=false | ||
| compress/lossy_quality=0.7 | ||
| compress/hdr_compression=1 | ||
| compress/normal_map=0 | ||
| compress/channel_pack=0 | ||
| mipmaps/generate=false | ||
| mipmaps/limit=-1 | ||
| roughness/mode=0 | ||
| roughness/src_normal="" | ||
| process/fix_alpha_border=true | ||
| process/premult_alpha=false | ||
| process/normal_map_invert_y=false | ||
| process/hdr_as_srgb=false | ||
| process/hdr_clamp_exposure=false | ||
| process/size_limit=0 | ||
| detect_3d/compress_to=1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [remap] | ||
|
|
||
| importer="texture" | ||
| type="CompressedTexture2D" | ||
| uid="uid://dg4tnp7plxmp7" | ||
| path="res://.godot/imported/relic_GoodVibes.png-cd102b29bb163411bb7ce8cf724ef0c0.ctex" | ||
| metadata={ | ||
| "vram_texture": false | ||
| } | ||
|
|
||
| [deps] | ||
|
|
||
| source_file="res://Classes/Relics/assets/relic_GoodVibes.png" | ||
| dest_files=["res://.godot/imported/relic_GoodVibes.png-cd102b29bb163411bb7ce8cf724ef0c0.ctex"] | ||
|
|
||
| [params] | ||
|
|
||
| compress/mode=0 | ||
| compress/high_quality=false | ||
| compress/lossy_quality=0.7 | ||
| compress/hdr_compression=1 | ||
| compress/normal_map=0 | ||
| compress/channel_pack=0 | ||
| mipmaps/generate=false | ||
| mipmaps/limit=-1 | ||
| roughness/mode=0 | ||
| roughness/src_normal="" | ||
| process/fix_alpha_border=true | ||
| process/premult_alpha=false | ||
| process/normal_map_invert_y=false | ||
| process/hdr_as_srgb=false | ||
| process/hdr_clamp_exposure=false | ||
| process/size_limit=0 | ||
| detect_3d/compress_to=1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| using Godot; | ||
|
|
||
| namespace FunkEngine; | ||
|
|
||
| public enum ArrowType | ||
| { | ||
| Up = 0, | ||
| Down = 1, | ||
| Left = 2, | ||
| Right = 3, | ||
| } | ||
|
|
||
| public enum BattleEffectTrigger | ||
| { | ||
| NotePlaced, | ||
| NoteHit, | ||
| SelfNoteHit, | ||
| OnPickup, | ||
| } | ||
|
|
||
| public enum Timing | ||
| { | ||
| Miss = 0, | ||
| Bad = 1, | ||
| Okay = 2, | ||
| Good = 3, | ||
| Perfect = 4, | ||
| } | ||
|
|
||
| public enum Stages | ||
| { | ||
| Title, | ||
| Battle, | ||
| Quit, | ||
| Map, | ||
| } | ||
|
|
||
| public struct SongData | ||
| { | ||
| public int Bpm; | ||
| public double SongLength; | ||
| public int NumLoops; | ||
| } | ||
|
|
||
| public struct ArrowData | ||
| { | ||
| public Color Color; | ||
| public string Key; | ||
| public NoteChecker Node; | ||
| public ArrowType Type; | ||
| } | ||
|
|
||
| public interface IBattleEvent | ||
| { | ||
| void OnTrigger(BattleDirector BD); | ||
| BattleEffectTrigger GetTrigger(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use consistent property encapsulation and add documentation.
Consider using properties consistently and adding XML documentation for better maintainability.
📝 Committable suggestion