diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 63f6a8b7..e4672c6f 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -227,7 +227,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I for (key in animOffsets.keys()) { final point = animOffsets[key]; animOffsets.remove(key); - if(point != null) + if (point != null) point.put(); } animOffsets = null; @@ -322,19 +322,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I return animateAtlas != null ? (animateAtlas.anim.animsMap.exists(AnimName) || animateAtlas.anim.symbolDictionary.exists(AnimName)) : animation.exists(AnimName); - public inline function getAnimName() - { - var name = null; - if (animateAtlas != null) - { - name = atlasPlayingAnim; - } - else - { - if (animation.curAnim != null) - name = animation.curAnim.name; - } - return name; + public inline function getAnimName() { + return (animateAtlas != null) ? atlasPlayingAnim : animation.name; } public inline function removeAnimation(name:String) { @@ -358,8 +347,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I animation.stop(); } - public inline function isAnimFinished() - { + public inline function isAnimFinished() { return animateAtlas != null ? (animateAtlas.anim.finished) : (animation.curAnim != null ? animation.curAnim.finished : true); } #end diff --git a/source/funkin/backend/utils/MemoryUtil.hx b/source/funkin/backend/utils/MemoryUtil.hx index 6905d6b2..85f7d145 100644 --- a/source/funkin/backend/utils/MemoryUtil.hx +++ b/source/funkin/backend/utils/MemoryUtil.hx @@ -134,7 +134,7 @@ class MemoryUtil { if (process.exitCode() != 0) return "Unknown"; var lines = process.stdout.readAll().toString().split("\n"); for (line in lines) { - if (line.indexOf("Type:") == 0) { + if (line.startsWith("Type:")) { return line.substring("Type:".length).trim(); } } diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 1071763a..c20382d8 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1811,7 +1811,7 @@ class Charter extends UIState { public inline function __fixSelection(selection:Selection):Selection { var newSelection:Selection = new Selection(); - for (s in selection) if (newSelection.indexOf(s) == -1) newSelection.push(s); + for (s in selection) if (!newSelection.contains(s)) newSelection.push(s); return newSelection.filter((s:ICharterSelectable) -> {return s != null;}); } diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index b8baf48e..01d2824b 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -290,7 +290,7 @@ class Note extends FlxSprite setClipRect(swagRect); } - public function setClipRect(rect:FlxRect) { + public inline function setClipRect(rect:FlxRect) { this.clipRect = rect; } diff --git a/source/funkin/game/NoteGroup.hx b/source/funkin/game/NoteGroup.hx index 0d45a41f..98b6477e 100644 --- a/source/funkin/game/NoteGroup.hx +++ b/source/funkin/game/NoteGroup.hx @@ -106,8 +106,7 @@ class NoteGroup extends FlxTypedGroup { if (members == null) return null; - // TODO: maybe lastIndexOf - var index:Int = members.indexOfFromLast(Object); + var index:Int = members.lastIndexOf(Object); if (index < 0) return null; diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index a9b6403e..a3908317 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1677,8 +1677,9 @@ class PlayState extends MusicBeatState } public function displayRating(myRating:String, ?evt:NoteHitEvent = null):Void { - var pre:String = evt != null ? evt.ratingPrefix : ""; - var suf:String = evt != null ? evt.ratingSuffix : ""; + var hasEvent = evt != null; + var pre:String = hasEvent ? evt.ratingPrefix : ""; + var suf:String = hasEvent ? evt.ratingSuffix : ""; var rating:FlxSprite = comboGroup.recycleLoop(FlxSprite); rating.resetSprite(comboGroup.x + -40, comboGroup.y + -60); @@ -1686,7 +1687,7 @@ class PlayState extends MusicBeatState rating.acceleration.y = 550; rating.velocity.y -= FlxG.random.int(140, 175); rating.velocity.x -= FlxG.random.int(0, 10); - if (evt != null) { + if (hasEvent) { rating.scale.set(evt.ratingScale, evt.ratingScale); rating.antialiasing = evt.ratingAntialiasing; } @@ -1701,8 +1702,9 @@ class PlayState extends MusicBeatState } public function displayCombo(?evt:NoteHitEvent = null):Void { - var pre:String = evt != null ? evt.ratingPrefix : ""; - var suf:String = evt != null ? evt.ratingSuffix : ""; + var hasEvent = evt != null; + var pre:String = hasEvent ? evt.ratingPrefix : ""; + var suf:String = hasEvent ? evt.ratingSuffix : ""; var separatedScore:String = Std.string(combo).addZeros(3); @@ -1714,7 +1716,7 @@ class PlayState extends MusicBeatState comboSpr.velocity.y -= 150; comboSpr.velocity.x += FlxG.random.int(1, 10); - if (evt != null) { + if (hasEvent) { comboSpr.scale.set(evt.ratingScale, evt.ratingScale); comboSpr.antialiasing = evt.ratingAntialiasing; } @@ -1733,7 +1735,7 @@ class PlayState extends MusicBeatState { var numScore:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${pre}num${separatedScore.charAt(i)}${suf}')); numScore.resetSprite(comboGroup.x + (43 * i) - 90, comboGroup.y + 80); - if (evt != null) { + if (hasEvent) { numScore.antialiasing = evt.numAntialiasing; numScore.scale.set(evt.numScale, evt.numScale); }