Skip to content

Commit 2418e14

Browse files
authored
Warn when FLX_HEALTH or FLX_NO_HEALTH is not defined, deprecate tilemap.rayStep (#3407)
* warn about the FLX_HEALTH flag * deprecate FlxBaseTilemap.rayStep * deprecate RAY_STEP path simplification
1 parent e42d9bc commit 2418e14

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

flixel/FlxObject.hx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package flixel;
22

3-
import openfl.display.Graphics;
43
import flixel.group.FlxGroup.FlxTypedGroup;
54
import flixel.math.FlxPoint;
65
import flixel.math.FlxRect;
@@ -13,6 +12,7 @@ import flixel.util.FlxDestroyUtil;
1312
import flixel.util.FlxDirectionFlags;
1413
import flixel.util.FlxSpriteUtil;
1514
import flixel.util.FlxStringUtil;
15+
import openfl.display.Graphics;
1616

1717
/**
1818
* At their core `FlxObjects` are just boxes with positions that can move and collide with other
@@ -46,7 +46,7 @@ import flixel.util.FlxStringUtil;
4646
* FlxG.overlap(playerGroup, medKitGroup
4747
* function onOverlap(player, medKit)
4848
* {
49-
* player.health = 100;
49+
* player.heal(100);
5050
* medKit.kill();
5151
* }
5252
* );
@@ -670,7 +670,9 @@ class FlxObject extends FlxBasic
670670
/**
671671
* Handy for storing health percentage or armor points or whatever.
672672
*/
673-
@:deprecated("object.health is being removed in version 6.0.0")
673+
#if FLX_HEALTH_NOT_DEFINED
674+
@:deprecated("object.health is deprecated, add <haxedef name=\"FLX_HEALTH\"/> in your project.xml to continue using it")
675+
#end
674676
public var health:Float = 1;
675677
#end
676678

@@ -1160,7 +1162,10 @@ class FlxObject extends FlxBasic
11601162
*
11611163
* @param Damage How much health to take away (use a negative number to give a health bonus).
11621164
*/
1163-
@:deprecated("object.health is being removed in version 6.0.0")
1165+
1166+
#if FLX_HEALTH_NOT_DEFINED
1167+
@:deprecated("object.hurt is deprecated, add <haxedef name=\"FLX_HEALTH\"/> in your project.xml to continue using it")
1168+
#end
11641169
public function hurt(damage:Float):Void
11651170
{
11661171
health = health - damage;

flixel/path/FlxPathfinder.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class FlxTypedPathfinder<Tilemap:FlxBaseTilemap<FlxObject>, Data:FlxTypedPathfin
128128
* @param data The pathfinder data for this current search.
129129
* @param points An array of FlxPoint nodes.
130130
*/
131+
@:haxe.warning("-WDeprecated")
131132
function simplifyPath(data:Data, points:Array<FlxPoint>, simplify:FlxPathSimplifier):Array<FlxPoint>
132133
{
133134
switch(simplify)
@@ -242,6 +243,7 @@ class FlxTypedPathfinder<Tilemap:FlxBaseTilemap<FlxObject>, Data:FlxTypedPathfin
242243
* @param points An array of FlxPoint nodes.
243244
* @param reolution Defaults to 1, meaning check every tile or so. Higher means more checks!
244245
*/
246+
@:haxe.warning("-WDeprecated")
245247
function simplifyRayStep(data:Data, points:Array<FlxPoint>, resolution:Float):Void
246248
{
247249
// A point used to calculate rays
@@ -688,6 +690,7 @@ enum FlxPathSimplifier
688690
* Removes nodes who'with neighbors that have no walls directly blocking
689691
* Uses `tilemap.rayStep`.
690692
*/
693+
@:deprecated("RAY_STEP is deprecated, use RAY, instead")
691694
RAY_STEP(resolution:Float);
692695

693696
/**

flixel/system/macros/FlxDefines.hx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ private enum UserDefines
2626
FLX_NO_DEBUG;
2727
/* Removes FlxObject.health */
2828
FLX_NO_HEALTH;
29+
/* Enables FlxObject.health */
30+
FLX_HEALTH;
2931
FLX_RECORD;
3032
/* Defined in HaxeFlixel CI tests, do not use */
3133
FLX_UNIT_TEST;
@@ -103,7 +105,8 @@ private enum HelperDefines
103105
/* Used in HaxeFlixel CI, should have no effect on personal projects */
104106
FLX_NO_CI;
105107
FLX_SAVE;
106-
FLX_HEALTH;
108+
/** Neither FLX_HEALTH not FLX_NO_HEALTH was defined */
109+
FLX_HEALTH_NOT_DEFINED;
107110
FLX_NO_TRACK_POOLS;
108111
FLX_NO_TRACK_GRAPHICS;
109112
FLX_OPENGL_AVAILABLE;
@@ -210,10 +213,15 @@ class FlxDefines
210213
defineInversion(FLX_UNIT_TEST, FLX_NO_UNIT_TEST);
211214
defineInversion(FLX_COVERAGE_TEST, FLX_NO_COVERAGE_TEST);
212215
defineInversion(FLX_SWF_VERSION_TEST, FLX_NO_SWF_VERSION_TEST);
213-
defineInversion(FLX_NO_HEALTH, FLX_HEALTH);
214216
defineInversion(FLX_TRACK_POOLS, FLX_NO_TRACK_POOLS);
215217
defineInversion(FLX_DEFAULT_SOUND_EXT, FLX_NO_DEFAULT_SOUND_EXT);
216218
// defineInversion(FLX_TRACK_GRAPHICS, FLX_NO_TRACK_GRAPHICS); // special case
219+
// defineInversion(FLX_NO_HEALTH, FLX_HEALTH);
220+
if (!defined(FLX_NO_HEALTH) && !defined(FLX_HEALTH))
221+
{
222+
define(FLX_HEALTH_NOT_DEFINED);
223+
define(FLX_HEALTH);
224+
}
217225
}
218226

219227
static function defineHelperDefines()

flixel/tile/FlxBaseTilemap.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class FlxBaseTilemap<Tile:FlxObject> extends FlxObject
235235
* @return Returns true if the ray made it from Start to End without hitting anything.
236236
* Returns false and fills Result if a tile was hit.
237237
*/
238+
@:deprecated("rayStep is deprecated, ray() has an infinite resolution, without any loss in performance")
238239
public function rayStep(start:FlxPoint, end:FlxPoint, ?result:FlxPoint, resolution:Float = 1):Bool
239240
{
240241
throw "rayStep must be implemented?";

tests/unit/src/flixel/system/frontEnds/ConsoleFrontEndTest.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import massive.munit.Assert;
1010
class ConsoleFrontEndTest
1111
{
1212
@Test
13-
#if !debug @Ignore #end
13+
#if (!debug || hl) @Ignore #end // Fails on HL: https://github.com/HaxeFoundation/hashlink/issues/769
1414
function testEnum()
1515
{
1616
FlxG.console.registerEnum(TestEnum);

tests/unit/src/flixel/tile/FlxTilemapTest.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ class FlxTilemapTest extends FlxTest
674674
}
675675

676676
@Test
677+
@:haxe.warning("-WDeprecated")
677678
function testNegativeIndex()
678679
{
679680
final mapData = [

0 commit comments

Comments
 (0)