diff --git a/source/flx3d/Flx3DCamera.hx b/source/flx3d/Flx3DCamera.hx index 4e1da93d..129ace5d 100644 --- a/source/flx3d/Flx3DCamera.hx +++ b/source/flx3d/Flx3DCamera.hx @@ -87,7 +87,7 @@ class Flx3DCamera extends FlxCamera { default: new OBJParser(); }, (event:Asset3DEvent) -> { if (event.asset != null && event.asset.assetType == Asset3DType.MESH) { - var mesh:Mesh = cast(event.asset, Mesh); + var mesh:Mesh = cast event.asset; if (material != null) mesh.material = material; meshes.push(mesh); diff --git a/source/flx3d/Flx3DView.hx b/source/flx3d/Flx3DView.hx index e76500c3..5413fe94 100644 --- a/source/flx3d/Flx3DView.hx +++ b/source/flx3d/Flx3DView.hx @@ -60,7 +60,7 @@ class Flx3DView extends FlxView3D { default: new OBJParser(); }, (event:Asset3DEvent) -> { if (event.asset != null && event.asset.assetType == Asset3DType.MESH) { - var mesh:Mesh = cast(event.asset, Mesh); + var mesh:Mesh = cast event.asset; if (material != null) mesh.material = material; meshes.push(mesh); diff --git a/source/funkin/backend/MusicBeatGroup.hx b/source/funkin/backend/MusicBeatGroup.hx index ec6f2693..5cccf0f6 100644 --- a/source/funkin/backend/MusicBeatGroup.hx +++ b/source/funkin/backend/MusicBeatGroup.hx @@ -4,12 +4,12 @@ import funkin.backend.system.interfaces.IBeatReceiver; class MusicBeatGroup extends FlxTypedSpriteGroup implements IBeatReceiver { public function beatHit(curBeat:Int) { - for(e in members) if (e is IBeatReceiver) cast(e, IBeatReceiver).beatHit(curBeat); + for(e in members) if (e is IBeatReceiver) ({var _:IBeatReceiver = cast e;_;}).beatHit(curBeat); } public function stepHit(curStep:Int) { - for(e in members) if (e is IBeatReceiver) cast(e, IBeatReceiver).stepHit(curStep); + for(e in members) if (e is IBeatReceiver) ({var _:IBeatReceiver = cast e;_;}).stepHit(curStep); } public function measureHit(curMeasure:Int) { - for(e in members) if (e is IBeatReceiver) cast(e, IBeatReceiver).measureHit(curMeasure); + for(e in members) if (e is IBeatReceiver) ({var _:IBeatReceiver = cast e;_;}).measureHit(curMeasure); } } \ No newline at end of file diff --git a/source/funkin/backend/MusicBeatState.hx b/source/funkin/backend/MusicBeatState.hx index e519ed0e..56dc1874 100644 --- a/source/funkin/backend/MusicBeatState.hx +++ b/source/funkin/backend/MusicBeatState.hx @@ -192,19 +192,19 @@ class MusicBeatState extends FlxState implements IBeatReceiver @:dox(hide) public function stepHit(curStep:Int):Void { - for(e in members) if (e != null && e is IBeatReceiver) cast(e, IBeatReceiver).stepHit(curStep); + for(e in members) if (e != null && e is IBeatReceiver) ({var _:IBeatReceiver=cast e;_;}).stepHit(curStep); call("stepHit", [curStep]); } @:dox(hide) public function beatHit(curBeat:Int):Void { - for(e in members) if (e != null && e is IBeatReceiver) cast(e, IBeatReceiver).beatHit(curBeat); + for(e in members) if (e != null && e is IBeatReceiver) ({var _:IBeatReceiver=cast e;_;}).beatHit(curBeat); call("beatHit", [curBeat]); } @:dox(hide) public function measureHit(curMeasure:Int):Void { - for(e in members) if (e != null && e is IBeatReceiver) cast(e, IBeatReceiver).measureHit(curMeasure); + for(e in members) if (e != null && e is IBeatReceiver) ({var _:IBeatReceiver=cast e;_;}).measureHit(curMeasure); call("measureHit", [curMeasure]); } @@ -278,8 +278,9 @@ class MusicBeatState extends FlxState implements IBeatReceiver public override function resetSubState() { super.resetSubState(); if (subState != null && subState is MusicBeatSubstate) { - cast(subState, MusicBeatSubstate).parent = this; - cast(subState, MusicBeatSubstate).onSubstateOpen(); + var subState:MusicBeatSubstate = cast subState; + subState.parent = this; + subState.onSubstateOpen(); } } } diff --git a/source/funkin/backend/MusicBeatSubstate.hx b/source/funkin/backend/MusicBeatSubstate.hx index d8ee8076..b8d26038 100644 --- a/source/funkin/backend/MusicBeatSubstate.hx +++ b/source/funkin/backend/MusicBeatSubstate.hx @@ -181,19 +181,19 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver @:dox(hide) public function stepHit(curStep:Int):Void { - for(e in members) if (e is IBeatReceiver) cast(e, IBeatReceiver).stepHit(curStep); + for(e in members) if (e is IBeatReceiver) ({var _:IBeatReceiver=cast e;_;}).stepHit(curStep); call("stepHit", [curStep]); } @:dox(hide) public function beatHit(curBeat:Int):Void { - for(e in members) if (e is IBeatReceiver) cast(e, IBeatReceiver).beatHit(curBeat); + for(e in members) if (e is IBeatReceiver) ({var _:IBeatReceiver=cast e;_;}).beatHit(curBeat); call("beatHit", [curBeat]); } @:dox(hide) public function measureHit(curMeasure:Int):Void { - for(e in members) if (e is IBeatReceiver) cast(e, IBeatReceiver).measureHit(curMeasure); + for(e in members) if (e is IBeatReceiver) ({var _:IBeatReceiver=cast e;_;}).measureHit(curMeasure); call("measureHit", [curMeasure]); } @@ -256,7 +256,8 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver public override function resetSubState() { if (subState != null && subState is MusicBeatSubstate) { - cast(subState, MusicBeatSubstate).parent = this; + var subState:MusicBeatSubstate = cast subState; + subState.parent = this; super.resetSubState(); if (subState != null) cast(subState, MusicBeatSubstate).onSubstateOpen(); diff --git a/source/funkin/backend/scripting/MultiThreadedScript.hx b/source/funkin/backend/scripting/MultiThreadedScript.hx index 3ba51f52..24754c7c 100644 --- a/source/funkin/backend/scripting/MultiThreadedScript.hx +++ b/source/funkin/backend/scripting/MultiThreadedScript.hx @@ -33,8 +33,8 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe if (parentScript != null) { if (script is HScript && parentScript is HScript) { - var hscript = cast(script, HScript); - var parentHScript = cast(parentScript, HScript); + var hscript:HScript = cast script; + var parentHScript:HScript = cast parentScript; hscript.interp.variables = parentHScript.interp.variables; hscript.interp.publicVariables = parentHScript.interp.publicVariables; diff --git a/source/funkin/backend/system/Conductor.hx b/source/funkin/backend/system/Conductor.hx index 8d4ef85a..f9758b94 100644 --- a/source/funkin/backend/system/Conductor.hx +++ b/source/funkin/backend/system/Conductor.hx @@ -181,7 +181,11 @@ class Conductor private static var __updateMeasure:Bool; private static function update() { - if (FlxG.state != null && FlxG.state is MusicBeatState && cast(FlxG.state, MusicBeatState).cancelConductorUpdate) return; + if (FlxG.state != null && FlxG.state is MusicBeatState) { + var state:MusicBeatState = cast FlxG.state; + if(state.cancelConductorUpdate) + return; + } __updateSongPos(FlxG.elapsed); @@ -233,7 +237,7 @@ class Conductor var state = FlxG.state; while(state != null) { if (state is IBeatReceiver && (state.subState == null || state.persistentUpdate)) { - var st = cast(state, IBeatReceiver); + var st:IBeatReceiver = cast state; if (curStep > oldStep) { for(i in oldStep...curStep) { st.stepHit(i+1); diff --git a/source/funkin/backend/system/framerate/SystemInfo.hx b/source/funkin/backend/system/framerate/SystemInfo.hx index a815e3b5..e736b7d2 100644 --- a/source/funkin/backend/system/framerate/SystemInfo.hx +++ b/source/funkin/backend/system/framerate/SystemInfo.hx @@ -91,7 +91,7 @@ class SystemInfo extends FramerateCategory { #end if(openfl.display3D.Context3D.__glMemoryTotalAvailable != -1) { - var vRAMBytes:UInt = cast(flixel.FlxG.stage.context3D.gl.getParameter(openfl.display3D.Context3D.__glMemoryTotalAvailable), UInt); + var vRAMBytes:UInt = cast flixel.FlxG.stage.context3D.gl.getParameter(openfl.display3D.Context3D.__glMemoryTotalAvailable); if (vRAMBytes == 1000 || vRAMBytes == 1 || vRAMBytes <= 0) Logs.trace('Unable to grab GPU VRAM', ERROR, RED); else diff --git a/source/funkin/backend/system/modules/CrashHandler.hx b/source/funkin/backend/system/modules/CrashHandler.hx index 124b915c..1debede9 100644 --- a/source/funkin/backend/system/modules/CrashHandler.hx +++ b/source/funkin/backend/system/modules/CrashHandler.hx @@ -20,10 +20,10 @@ class CrashHandler { public static function onUncaughtError(e:UncaughtErrorEvent) { var m:String = e.error; if (Std.isOfType(e.error, Error)) { - var err = cast(e.error, Error); + var err:Error = cast e.error; m = '${err.message}'; } else if (Std.isOfType(e.error, ErrorEvent)) { - var err = cast(e.error, ErrorEvent); + var err:ErrorEvent = cast e.error; m = '${err.text}'; } var stack = CallStack.exceptionStack(); diff --git a/source/funkin/backend/utils/MemoryUtil.hx b/source/funkin/backend/utils/MemoryUtil.hx index ac807088..6c27629e 100644 --- a/source/funkin/backend/utils/MemoryUtil.hx +++ b/source/funkin/backend/utils/MemoryUtil.hx @@ -151,25 +151,4 @@ class MemoryUtil { #end return "Unknown"; } - - private static var _nb:Int = 0; - private static var _nbD:Int = 0; - private static var _zombie:Dynamic; - - public static function destroyFlixelZombies() { - #if cpp - // Gc.enterGCFreeZone(); - - while ((_zombie = Gc.getNextZombie()) != null) { - _nb++; - if (_zombie is flixel.util.FlxDestroyUtil.IFlxDestroyable) { - flixel.util.FlxDestroyUtil.destroy(cast(_zombie, flixel.util.FlxDestroyUtil.IFlxDestroyable)); - _nbD++; - } - } - Sys.println('Zombies: ${_nb}; IFlxDestroyable Zombies: ${_nbD}'); - - // Gc.exitGCFreeZone(); - #end - } } \ No newline at end of file diff --git a/source/funkin/backend/utils/NativeAPI.hx b/source/funkin/backend/utils/NativeAPI.hx index 78f0b38d..45759231 100644 --- a/source/funkin/backend/utils/NativeAPI.hx +++ b/source/funkin/backend/utils/NativeAPI.hx @@ -113,8 +113,8 @@ class NativeAPI { if(backgroundColor == NONE) backgroundColor = BLACK; - var fg = cast(foregroundColor, Int); - var bg = cast(backgroundColor, Int); + var fg:Int = cast foregroundColor; + var bg:Int = cast backgroundColor; Windows.setConsoleColors((bg * 16) + fg); #elseif sys Sys.print("\x1b[0m"); diff --git a/source/funkin/backend/utils/XMLUtil.hx b/source/funkin/backend/utils/XMLUtil.hx index 6ff7c1d6..30bbc380 100644 --- a/source/funkin/backend/utils/XMLUtil.hx +++ b/source/funkin/backend/utils/XMLUtil.hx @@ -252,7 +252,7 @@ class XMLUtil { cast(sprite, IOffsetCompatible).addOffset(animData.name, animData.x, animData.y); if (sprite is FunkinSprite) { - var xmlSpr = cast(sprite, FunkinSprite); + var xmlSpr:FunkinSprite = cast sprite; var name = animData.name; switch(animData.animType) { case BEAT: diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index dc862cc4..5b065029 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -675,7 +675,8 @@ class Charter extends UIState { } for (group in [notesGroup, eventsGroup]) { - cast(group, FlxTypedGroup).forEach(function(s) { + var group:FlxTypedGroup = cast group; + group.forEach(function(s) { s.selected = false; if (gridActionType == NONE) { if (s is CharterNote) { @@ -740,21 +741,27 @@ class Charter extends UIState { selectionBox.bHeight = Std.int(Math.abs(mousePos.y - dragStartPos.y)); } else { if (FlxG.keys.pressed.SHIFT) { - for (group in [notesGroup, eventsGroup]) - for(n in cast(group, FlxTypedGroup)) + for (group in [notesGroup, eventsGroup]) { + var group:FlxTypedGroup = cast group; + for(n in group) if (n.handleSelection(selectionBox) && selection.contains(n)) selection.remove(n); + } } else if (FlxG.keys.pressed.CONTROL) { - for (group in [notesGroup, eventsGroup]) - for(n in cast(group, FlxTypedGroup)) + for (group in [notesGroup, eventsGroup]) { + var group:FlxTypedGroup = cast group; + for(n in group) if (n.handleSelection(selectionBox) && !selection.contains(n)) selection.push(n); + } } else { selection = []; - for (group in [notesGroup, eventsGroup]) - for(n in cast(group, FlxTypedGroup)) + for (group in [notesGroup, eventsGroup]) { + var group:FlxTypedGroup = cast group; + for(n in group) if (n.handleSelection(selectionBox)) selection.push(n); + } } selection = __fixSelection(selection); @@ -810,8 +817,14 @@ class Charter extends UIState { changePoint.put(); } - if (s is CharterNote) cast(s, CharterNote).snappedToStrumline = true; - if (s is UISprite) cast(s, UISprite).cursor = BUTTON; + if (s is CharterNote) { + var s:CharterNote = cast s; + s.snappedToStrumline = true; + } + if (s is UISprite) { + var s:UISprite = cast s; + s.cursor = BUTTON; + } } if (!(verticalChange == 0 && horizontalChange == 0)) { notesGroup.sortNotes(); eventsGroup.sortEvents(); @@ -1016,9 +1029,9 @@ class Charter extends UIState { if (selection.length <= 0) return []; notesGroup.autoSort = false; - for (objects in [notesGroup, eventsGroup]) { - var group = cast(objects, FlxTypedGroup); - var member = 0; + for (group in [notesGroup, eventsGroup]) { + var group:FlxTypedGroup = cast group; + var member:Int = 0; while(member < group.members.length) { var s = group.members[member]; if (selection.contains(s)) @@ -1375,7 +1388,7 @@ class Charter extends UIState { var note:CharterNote = cast s; CNote(note.step - minStep, note.id, note.strumLineID, note.susLength, note.type); } else if (s is CharterEvent) { - var event = cast(s,CharterEvent); + var event:CharterEvent = cast s; CEvent(event.step - minStep, [for (event in event.events) Reflect.copy(event)]); } ]; @@ -1957,9 +1970,9 @@ typedef SelectionDragChange = { public inline function loop(onNote:CharterNote->Void, ?onEvent:CharterEvent->Void, ?draggableOnly:Bool = true) { for (s in this) { if (s is CharterNote && onNote != null && (draggableOnly ? s.draggable: true)) - onNote(cast(s, CharterNote)); + onNote(cast s); else if (s is CharterEvent && onEvent != null && (draggableOnly ? s.draggable: true)) - onEvent(cast(s, CharterEvent)); + onEvent(cast s); } } } diff --git a/source/funkin/editors/charter/CharterEvent.hx b/source/funkin/editors/charter/CharterEvent.hx index af8996a4..1a0abe81 100644 --- a/source/funkin/editors/charter/CharterEvent.hx +++ b/source/funkin/editors/charter/CharterEvent.hx @@ -63,7 +63,7 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable { generateDefaultIcon(event.name); case "Camera Movement": // custom icon for camera movement - var state = cast(FlxG.state, Charter); + var state:Charter = cast FlxG.state; if (event.params != null && event.params[0] != null && event.params[0] >= 0 && event.params[0] < state.strumLines.length) { // camera movement, use health icon var icon = Character.getIconFromCharName(state.strumLines.members[event.params[0]].strumLine.characters[0]); diff --git a/source/funkin/editors/charter/CharterNoteGroup.hx b/source/funkin/editors/charter/CharterNoteGroup.hx index 4c9a1d87..c2c2e388 100644 --- a/source/funkin/editors/charter/CharterNoteGroup.hx +++ b/source/funkin/editors/charter/CharterNoteGroup.hx @@ -33,7 +33,7 @@ class CharterNoteGroup extends FlxTypedGroup { noteFunc(__loopSprite); } for(c in Charter.selection.copy()) - if (c != null && c is CharterNote) noteFunc(cast (c, CharterNote)); + if (c != null && c is CharterNote) noteFunc(cast c); __currentlyLooping = oldCur; } diff --git a/source/funkin/editors/charter/CharterNoteHoverer.hx b/source/funkin/editors/charter/CharterNoteHoverer.hx index e20000a2..3ef2e543 100644 --- a/source/funkin/editors/charter/CharterNoteHoverer.hx +++ b/source/funkin/editors/charter/CharterNoteHoverer.hx @@ -47,7 +47,7 @@ class CharterNoteHoverer extends CharterNote { for (s in Charter.selection) { if (s != null && s.draggable && s is CharterNote) { - var draggingNote:CharterNote = cast(s, CharterNote); + var draggingNote:CharterNote = cast s; y = (draggingNote.step + verticalChange); if (!FlxG.keys.pressed.SHIFT) y -= ((draggingNote.step + verticalChange) diff --git a/source/funkin/editors/ui/UIFileExplorer.hx b/source/funkin/editors/ui/UIFileExplorer.hx index 7cc16320..a122dcec 100644 --- a/source/funkin/editors/ui/UIFileExplorer.hx +++ b/source/funkin/editors/ui/UIFileExplorer.hx @@ -55,8 +55,10 @@ class UIFileExplorer extends UISliceSprite { if (uiElement != null) { uiElement.alpha = alpha; - if (uiElement is UIButton) - cast(uiElement, UIButton).selectable = selectable; + if (uiElement is UIButton) { + var uiElement:UIButton = cast uiElement; + uiElement.selectable = selectable; + } } } diff --git a/source/funkin/editors/ui/UITopMenu.hx b/source/funkin/editors/ui/UITopMenu.hx index ae78469d..c4b0471d 100644 --- a/source/funkin/editors/ui/UITopMenu.hx +++ b/source/funkin/editors/ui/UITopMenu.hx @@ -21,9 +21,12 @@ class UITopMenu extends UISliceSprite { public override function update(elapsed:Float) { anyMenuOpened = false; - for(c in members) if (cast(c, UITopMenuButton).curMenu.contextMenuOpened()) { - anyMenuOpened = true; - break; + for(c in members) { + var c:UITopMenuButton = cast c; + if (c.curMenu.contextMenuOpened()) { + anyMenuOpened = true; + break; + } } super.update(elapsed); diff --git a/source/funkin/editors/ui/UIUtil.hx b/source/funkin/editors/ui/UIUtil.hx index 7f9de548..ac445a05 100644 --- a/source/funkin/editors/ui/UIUtil.hx +++ b/source/funkin/editors/ui/UIUtil.hx @@ -5,7 +5,7 @@ import funkin.editors.ui.UIContextMenu.UIContextMenuOption; class UIUtil { public static function follow(spr:FlxSprite, target:FlxSprite, x:Float = 0, y:Float = 0) { - spr.cameras = target is UISprite ? cast(target, UISprite).__lastDrawCameras : target.cameras; + spr.cameras = target is UISprite ? ({var _:UISprite = cast target;_;}).__lastDrawCameras : target.cameras; spr.setPosition(target.x + x, target.y + y); spr.scrollFactor.set(target.scrollFactor.x, target.scrollFactor.y); } diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index d043c040..f35dbc8d 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -436,7 +436,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset public static function getXMLFromCharName(character:OneOfTwo):Access { var char:Character = null; if (character is Character) { - char = cast(character, Character); + char = cast character; character = char.curCharacter; } diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index 21e70a6e..60aab276 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -213,7 +213,7 @@ class Note extends FlxSprite public var strumRelativePos:Bool = true; override function drawComplex(camera:FlxCamera) { - var downscrollCam = (camera is HudCamera ? cast(camera, HudCamera).downscroll : false); + var downscrollCam = (camera is HudCamera ? ({var _:HudCamera=cast camera;_;}).downscroll : false); flipY = (isSustainNote && flipSustain) && (downscrollCam != (__strum != null && __strum.getScrollSpeed(this) < 0)); if (downscrollCam) { frameOffset.y += __notePosFrameOffset.y * 2; diff --git a/source/funkin/menus/ui/Alphabet.hx b/source/funkin/menus/ui/Alphabet.hx index 663fa1b1..dfc86584 100644 --- a/source/funkin/menus/ui/Alphabet.hx +++ b/source/funkin/menus/ui/Alphabet.hx @@ -41,7 +41,7 @@ class Alphabet extends FlxSpriteGroup private override function set_color(c:Int):Int { for(e in group.members) { if (e is AlphaCharacter) { - var char = cast(e, AlphaCharacter); + var char:AlphaCharacter = cast e; char.setColor(c, isBold); } }